Skip to content

Commit 9485e81

Browse files
committed
Install python through UV and other feedback
- Fix the docs makefile - Document pre-commit
1 parent a7b0a3c commit 9485e81

File tree

4 files changed

+35
-71
lines changed

4 files changed

+35
-71
lines changed

docker-compose/django/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ ENV PYTHONUNBUFFERED 1
1010
# Copy (don't hardlink) files into /.venv. Avoid issues with Docker's FS
1111
# https://docs.astral.sh/uv/reference/environment/
1212
ENV UV_LINK_MODE=copy
13-
ENV UV_PYTHON_DOWNLOADS=never
1413
ENV UV_PROJECT_ENVIRONMENT=/.venv
1514

1615

@@ -25,8 +24,6 @@ RUN apt-get -y install \
2524
libxslt1-dev \
2625
locales \
2726
build-essential \
28-
python3-pip \
29-
python3-dev \
3027
postgresql-client \
3128
libmysqlclient-dev \
3229
libfreetype6 \
@@ -46,6 +43,10 @@ ENV PATH="/root/.local/bin/:$PATH"
4643
# uv.lock ensures reproducible builds
4744
COPY pyproject.toml uv.lock ./
4845

46+
# Install Python through uv
47+
# Get the version pinned by pyproject.toml
48+
RUN uv python install
49+
4950
# Install dependencies using uv sync
5051
# This creates a virtual environment at /.venv (not in /app)
5152
# This installs all dependencies from uv.lock, ensuring consistency

docs/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ BUILDDIR = _build
1010

1111
# Put it first so that "make" without argument is like "make help".
1212
help:
13-
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
13+
@uv run $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
1414

1515
livehtml:
16-
sphinx-autobuild -b html --port 4444 $(SPHINXOPTS) $(SOURCEDIR) $(BUILDDIR)/html
16+
@uv run sphinx-autobuild -b html --port 4444 $(SPHINXOPTS) $(SOURCEDIR) $(BUILDDIR)/html
1717

1818
.PHONY: help livehtml Makefile
1919

2020
# Catch-all target: route all unknown targets to Sphinx using the new
2121
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
2222
%: Makefile
23-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
23+
@uv run $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/developer/quickstart.rst

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,76 +20,75 @@ Start a local multi-container application with Postgres, Redis, Celery, and Djan
2020
2121
$ make dockerserve
2222
23-
To get a shell into the Django container where you can run ``./manage.py createsuperuser``,
23+
To get a shell into the Django container where you can run ``uv run ./manage.py createsuperuser``,
2424
get a Django shell, or run other commands:
2525

2626
.. code-block:: bash
2727
2828
$ make dockershell
2929
...
30-
/app # ./manage.py createsuperuser
30+
/app # uv run ./manage.py createsuperuser
3131
3232
After setting up your super user account on your local development instance,
3333
you'll still need to set the :ref:`install/installation:Set the ad server URL`
3434
to something like ``localhost:5000``.
3535

3636

37-
Developing locally
38-
------------------
37+
Development tips
38+
----------------
3939

4040
Docker compose is the recommended way to do development consistently.
41-
This section is more to document steps than to encourage you to develop outside of Docker.
41+
This step documents commands for code style, building static assets, and more.
42+
These commands can be run inside Docker (``make dockershell``).
4243

4344
Requirements
4445
~~~~~~~~~~~~
4546

46-
- Python 3.12
47+
- `uv <https://docs.astral.sh/uv/getting-started/installation/>`_
4748
- Nodejs (tested with v20)
4849

49-
Front-end assets
50-
~~~~~~~~~~~~~~~~
5150

52-
To build the assets::
51+
Managing the ad server and setup
52+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5353

54-
$ npm clean-install
55-
$ npm run build
56-
57-
Install Python dependencies
58-
~~~~~~~~~~~~~~~~~~~~~~~~~~~
59-
60-
First, install uv if you haven't already:
54+
Run migrations:
6155

6256
.. code-block:: bash
6357
64-
$ curl -LsSf https://astral.sh/uv/install.sh | sh
58+
$ uv run ./manage.py migrate
6559
66-
Then install dependencies:
60+
Create a superuser:
6761

6862
.. code-block:: bash
6963
70-
$ uv sync --all-extras # Install all dependencies including dev tools
71-
$ uv run pre-commit install # Install a code style pre-commit hook
64+
$ uv run ./manage.py createsuperuser
7265
73-
Run the server
74-
~~~~~~~~~~~~~~
66+
Front-end assets
67+
~~~~~~~~~~~~~~~~
7568

76-
Run migrations:
69+
To build the assets::
7770

7871
.. code-block:: bash
7972
80-
$ uv run ./manage.py migrate
73+
$ npm clean-install
74+
$ npm run build
8175
82-
Create a superuser:
76+
Pre-commit and code style
77+
~~~~~~~~~~~~~~~~~~~~~~~~~
78+
79+
Setup pre-commit:
8380

8481
.. code-block:: bash
8582
86-
$ uv run ./manage.py createsuperuser
83+
$ uv tool install pre-commit --with pre-commit-uv
84+
$ uvx pre-commit install # Install a code style pre-commit hook
8785
88-
Run the server:
86+
You can run all code style checks with teh following:
8987

9088
.. code-block:: bash
9189
92-
$ uv run ./manage.py runserver
90+
$ uvx pre-commit run --all-files
91+
9392
9493
Running the tests
9594
-----------------
@@ -105,4 +104,4 @@ Run a specific test:
105104

106105
.. code-block:: bash
107106
108-
$ tox -e py3 -- adserver/auth/tests.py
107+
$ tox -e py3 -- adserver/auth/tests.py

docs/make.bat

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)