Skip to content

Commit 7079059

Browse files
authored
Add uv support for local development, CI, and Docker (#748)
1 parent c0f029c commit 7079059

3 files changed

Lines changed: 79 additions & 12 deletions

File tree

.github/workflows/ci.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v6
16-
- uses: actions/setup-python@v4
16+
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
1717
with:
18+
version: '0.11.16'
1819
python-version: '3.12'
19-
cache: 'pip'
20-
cache-dependency-path: 'requirements/*.txt'
21-
- run: pip install -r requirements/development.txt
20+
enable-cache: true
21+
- run: uv venv .venv
22+
- run: echo "$GITHUB_WORKSPACE/.venv/bin" >> "$GITHUB_PATH"
23+
- run: uv pip install --python .venv/bin/python -r requirements/development.txt
2224
- run: make lint-server
2325
lint-client:
2426
runs-on: ubuntu-latest
@@ -36,12 +38,14 @@ jobs:
3638
DJANGO_SETTINGS_MODULE: bakerydemo.settings.test
3739
steps:
3840
- uses: actions/checkout@v6
39-
- uses: actions/setup-python@v4
41+
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
4042
with:
43+
version: '0.11.16'
4144
python-version: '3.12'
42-
cache: 'pip'
43-
cache-dependency-path: 'requirements/*.txt'
44-
- run: pip install -r requirements/development.txt
45+
enable-cache: true
46+
- run: uv venv .venv
47+
- run: echo "$GITHUB_WORKSPACE/.venv/bin" >> "$GITHUB_PATH"
48+
- run: uv pip install --python .venv/bin/python -r requirements/development.txt
4549
- run: ./manage.py check
4650
- run: ./manage.py makemigrations --check --noinput
4751
- run: ./manage.py test

Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
ARG UV_VERSION=0.11.16
2+
FROM ghcr.io/astral-sh/uv:${UV_VERSION} AS uv
3+
14
FROM python:3.12-slim
25
ARG NIGHTLY=0
36

7+
COPY --from=uv /uv /uvx /bin/
8+
49
# Install packages needed to run your application (not build deps):
510
# We need to recreate the /usr/share/man/man{1..8} directories first because
611
# they were clobbered by a parent image.
@@ -39,9 +44,8 @@ RUN set -ex \
3944
grep -o 'https://[^"]*') \
4045
&& sed -i "s|wagtail>=.*|${NIGHTLY_URL}|" /requirements/base.txt; \
4146
fi \
42-
&& python3.12 -m venv ${VIRTUAL_ENV} \
43-
&& python3.12 -m pip install -U pip \
44-
&& python3.12 -m pip install --no-cache-dir -r /requirements/production.txt \
47+
&& uv venv ${VIRTUAL_ENV} \
48+
&& uv pip install --python ${VIRTUAL_ENV}/bin/python -r /requirements/production.txt \
4549
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \
4650
&& rm -rf /var/lib/apt/lists/*
4751

readme.md

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ This demo is aimed primarily at developers wanting to learn more about the inter
3131
# Installation
3232

3333
- [Venv](#setup-with-venv)
34+
- [uv](#setup-with-uv)
3435
- [Vagrant](#setup-with-vagrant)
3536
- [Docker](#setup-with-docker)
3637

@@ -141,7 +142,7 @@ On Windows, activate the virtual environment using the appropriate command for y
141142
> - allow scripts in PowerShell for your user account:
142143
> `Set-ExecutionPolicy -Scope CurrentUser RemoteSigned`
143144
144-
Now we're ready to set up the bakery demo project itself:
145+
Now we're ready to set up the bakerydemo project itself:
145146
```bash
146147
cd ~/dev [or your preferred dev directory]
147148
git clone https://github.com/wagtail/bakerydemo.git
@@ -165,6 +166,64 @@ To set up your database and load initial data, run the following commands:
165166

166167
Log into the admin with the credentials `admin / changeme`.
167168

169+
## Setup with uv
170+
171+
If you prefer [uv](https://docs.astral.sh/uv/), bakerydemo also supports the existing requirements-based workflow with uv-managed environments. This is optional and is intended as an additional local development path alongside manual `venv` usage.
172+
173+
#### Dependencies
174+
175+
- [uv](https://docs.astral.sh/uv/getting-started/installation/)
176+
177+
Install `uv` using one of the methods from the official installation guide.
178+
For example, on macOS and Linux:
179+
180+
```bash
181+
curl -LsSf https://astral.sh/uv/install.sh | sh
182+
```
183+
184+
### Installation
185+
186+
Now we're ready to set up the bakerydemo project itself:
187+
188+
```bash
189+
cd ~/dev [or your preferred dev directory]
190+
git clone https://github.com/wagtail/bakerydemo.git
191+
cd bakerydemo
192+
```
193+
194+
Create and activate a virtual environment with uv:
195+
196+
On macOS / GNU/Linux:
197+
```bash
198+
uv venv .venv
199+
source .venv/bin/activate
200+
```
201+
202+
On Windows, activate the virtual environment using the appropriate command for your shell:
203+
204+
```bash
205+
# PowerShell
206+
.venv\Scripts\Activate.ps1
207+
# Command Prompt (cmd.exe)
208+
.venv\Scripts\activate.bat
209+
```
210+
211+
Install the development dependencies:
212+
213+
```bash
214+
uv pip install -r requirements/development.txt
215+
```
216+
217+
Then continue with the same local configuration and database setup steps as in the `venv` instructions above:
218+
219+
```bash
220+
cp bakerydemo/settings/local.py.example bakerydemo/settings/local.py
221+
cp .env.example .env
222+
./manage.py migrate
223+
./manage.py load_initial_data
224+
./manage.py runserver
225+
```
226+
168227
# Next steps
169228

170229
After experimenting with the demo, you may want to create your own site. To do that, run the `wagtail start` command in your environment of choice. You can find more information in the [getting started Wagtail CMS docs](https://docs.wagtail.org/en/stable/getting_started/index.html).

0 commit comments

Comments
 (0)