Skip to content

Commit 6163dee

Browse files
committed
Merge branch 'uv'
2 parents 710a574 + f4a8c76 commit 6163dee

25 files changed

+2353
-3683
lines changed

Diff for: .devcontainer/complete-creation.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ set -o nounset
88
# For VSCode extension used to edit sphinx projects.
99
pip install esbonio
1010

11-
python manage.py createcachetable
12-
python manage.py migrate
11+
uv run python manage.py createcachetable
12+
uv run python manage.py migrate
1313

1414
npm install
1515

@@ -21,7 +21,7 @@ function setup-pre-commit() {
2121
sleep 30
2222
done
2323

24-
pre-commit install --hook-type pre-commit --hook-type pre-push
24+
uv run pre-commit install --hook-type pre-commit --hook-type pre-push
2525
}
2626

2727
# Run in the backend to allow VSCode to configure git.

Diff for: .dockerignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
.pre-commit-config.yaml
99
.readthedocs.yml
1010
.travis.yml
11-
venv
11+
venv/
12+
.venv/
1213
.git/
1314
devops/envs/
1415
.pytest_cache/

Diff for: .envrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
dotenv devops/envs/local/django
22
dotenv devops/envs/local/pycharm
33

4-
layout poetry
4+
uv sync
5+
source .venv/bin/activate

Diff for: .github/workflows/ci.yml

+44-27
Original file line numberDiff line numberDiff line change
@@ -19,49 +19,66 @@ concurrency:
1919
cancel-in-progress: true
2020

2121
jobs:
22-
linter:
22+
lint-and-test:
2323
runs-on: ubuntu-latest
24+
services:
25+
# Label used to access the service container
26+
postgres:
27+
# Docker Hub image
28+
image: postgres
29+
# Provide the password for postgres
30+
env:
31+
POSTGRES_HOST: localhost
32+
POSTGRES_PORT: 5432
33+
POSTGRES_DB: legadilo
34+
POSTGRES_USER: django
35+
POSTGRES_PASSWORD: django_passwd
36+
# Set health checks to wait until postgres has started
37+
options: >-
38+
--health-cmd pg_isready
39+
--health-interval 10s
40+
--health-timeout 5s
41+
--health-retries 5
42+
ports:
43+
# Maps tcp port 5432 on service container to the host
44+
- 5432:5432
45+
46+
env:
47+
IS_PRODUCTION: "false"
48+
PYTHONUNBUFFERED: "1"
49+
PYTHONDEVMODE: "1"
50+
USE_DOCKER: "no"
51+
DATABASE_URL: "postgres://django:django_passwd@localhost:5432/legadilo"
52+
2453
steps:
2554
- name: Checkout Code Repository
2655
uses: actions/checkout@v4
2756

28-
- name: Set up Python
29-
uses: actions/setup-python@v5
57+
- name: Install uv
58+
uses: astral-sh/setup-uv@v4
3059
with:
31-
python-version: "3.12"
60+
# Install a specific version of uv.
61+
version: "0.5.8"
3262

33-
- name: Install poetry
34-
run: pip install poetry==1.8.2
63+
- name: "Set up Python"
64+
uses: actions/setup-python@v5
65+
with:
66+
python-version-file: "pyproject.toml"
3567

36-
- name: Install typing deps
37-
run: poetry install --with typing
68+
- name: Install the project
69+
run: uv sync --dev --locked
3870

39-
# Consider using pre-commit.ci for open source project
4071
- name: Run pre-commit
41-
uses: pre-commit/[email protected]
42-
43-
# With no caching at all the entire ci process takes 4m 30s to complete!
44-
pytest:
45-
runs-on: ubuntu-latest
46-
47-
steps:
48-
- name: Checkout Code Repository
49-
uses: actions/checkout@v4
50-
51-
- name: Build the Stack
52-
run: docker compose -f local.yml build
72+
run: uv run pre-commit run -a
5373

5474
- name: Create cache table
55-
run: docker compose -f local.yml run --rm django python manage.py createcachetable
75+
run: uv run python manage.py createcachetable
5676

5777
- name: Run DB Migrations
58-
run: docker compose -f local.yml run --rm django python manage.py migrate
78+
run: uv run python manage.py migrate
5979

6080
- name: Run Django Tests
61-
run: docker compose -f local.yml run --rm django pytest --cov --cov-report term:skip-covered --cov-fail-under=90
62-
63-
- name: Tear down the Stack
64-
run: docker compose -f local.yml down
81+
run: uv run pytest --cov --cov-report term:skip-covered --cov-fail-under=90
6582

6683
- name: Test build production images
6784
run: |

Diff for: .idea/misc.xml

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/runConfigurations/Run_full_test_suite.xml

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/runConfigurations/Run_full_test_suite_and_update_snapshot.xml

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/runConfigurations/Run_full_test_suite_by_recreating_db.xml

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/runConfigurations/Runserver__with_interactive_debug_.xml

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/runConfigurations/Runserver__with_rich_logs_.xml

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .idea/runConfigurations/_template__of_py_test.xml

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: .pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ repos:
126126
- IS_PRODUCTION=True
127127
- DJANGO_SECRET_KEY=test-key
128128
- DJANGO_ADMIN_URL=admin/
129-
- poetry
129+
- uv
130130
- run
131131
- mypy
132132
- legadilo
@@ -141,7 +141,7 @@ repos:
141141
name: pytest
142142
entry: env
143143
args:
144-
- poetry
144+
- uv
145145
- run
146146
- pytest
147147
language: system

Diff for: CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
## Unreleased
44

5+
## 24.12.5
6+
57
- Add link to changelog in footer.
68
- Improve existing links in footer.
79
- Allow you to add a custom script.
810
- Can fetch feed without an explicit full site URL.
911
- Can force feeds to refresh in the admin.
1012
- Can refresh a reading list no mobile easily, without going to the top of the page or opening the reading list selector.
13+
- Switch to [`uv`](docs.astral.sh/uv/) to manage dependencies.
1114

1215
## 24.12.4
1316

Diff for: README.md

+11-8
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ You will have to start Django with the provided run target.
2828

2929
### Using Pycharm
3030

31-
By default, everything is set up to develop locally with Pycharm. So you will need docker (for the database), poetry, Python 3.12 and nodeJS 20+ installed for this to work. Django will be started automatically. On the first run, you must run `npm install` to install a few JS deps.
31+
By default, everything is set up to develop locally with Pycharm. So you will need docker (for the database), [uv](https://docs.astral.sh/uv/), Python 3.12 and nodeJS 20+ installed for this to work.
32+
Django will be started automatically.
33+
On the first run, you must run `npm install` to install a few JS deps and `uv run pre-commit install --hook-type pre-commit --hook-type pre-push` to configure `pre-commit`.
3234

33-
You should also be able to use devcontainers but the support is more recent and isn’t as good as in VSCode according to my tests. See [here](https://www.jetbrains.com/help/pycharm/connect-to-devcontainer.html) for more.
35+
You should also be able to use devcontainers but the support is more recent and isn’t as good as in VSCode according to my tests.
36+
See [here](https://www.jetbrains.com/help/pycharm/connect-to-devcontainer.html) for more.
3437

3538
### Project structure
3639

@@ -46,16 +49,16 @@ You should also be able to use devcontainers but the support is more recent and
4649
- `.decontainer/`, `.idea/`, `.vscode/` and `.editorconfig` are editors configuration.
4750
- `.eslintrc.json`, `prettierrc.json` and `.stylelintrc.json` contains the JS/CSS linters and formatters configurations.
4851
- `pyproject.toml` defines the Python dependencies and is used to configure Python linting tools.
49-
- `poetry.lock` and `package-lock.json` are used to lock the dependencies.
52+
- `uv.lock` and `package-lock.json` are used to lock the dependencies.
5053

5154
### Basic Commands
5255

5356
All these commands must be run at the root of the project!
5457

55-
- Run the server: `python manage.py runserver`
56-
- Create migrations files after updating models: `python manage.py makemigrations`
57-
- Apply migrations: `python manage.py migrate`
58-
- Create a _superuser_: `python manage.py createsuperuser`
58+
- Run the server: `uv run python manage.py runserver`
59+
- Create migrations files after updating models: `uv run python manage.py makemigrations`
60+
- Apply migrations: `uv run python manage.py migrate`
61+
- Create a _superuser_: `uv run python manage.py createsuperuser`
5962

6063
### Email Server
6164

@@ -71,7 +74,7 @@ With Mailpit running, to view messages that are sent by your application, open y
7174
- To create a **normal user account**, just go to Sign Up and fill out the form. Once you submit it, you'll see a "Verify Your E-mail Address" page. Go to Mailpit to see a simulated email verification message. Copy the link into your browser. Now the user's email should be verified and ready to go.
7275
- To create a **superuser account**, use this command:
7376

74-
$ python manage.py createsuperuser
77+
$ uv run python manage.py createsuperuser
7578

7679
For convenience, you can keep your normal user logged in on Chrome and your superuser logged in on Firefox (or similar), so that you can see how the site behaves for both kinds of users.
7780

Diff for: devops/compose/local/django/Dockerfile

+13-7
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,22 @@ ARG BUILD_ENVIRONMENT=local
44
ARG APP_HOME=/app
55
ARG PYTHONDEVMODE=1
66

7+
ENV UV_LINK_MODE copy
8+
ENV UV_COMPILE_BYTECODE 1
9+
ENV UV_PYTHON_DOWNLOADS never
10+
ENV UV_PROJECT_ENVIRONMENT ${APP_HOME}/.venv
11+
ENV UV_PYTHON /usr/local/bin/python
712
ENV PYTHONUNBUFFERED 1
813
ENV PYTHONDONTWRITEBYTECODE 1
914
ENV PYTHONDEVMODE ${PYTHONDEVMODE}
1015
ENV BUILD_ENV ${BUILD_ENVIRONMENT}
11-
ENV CREATE_VENV 0
16+
# make sure we use the virtualenv by default
17+
ENV PATH "${APP_HOME}/.venv/bin:$PATH"
1218

1319
WORKDIR ${APP_HOME}
1420

21+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
22+
1523
COPY ./devops/compose/production/django/setup-container.sh /
1624
RUN chmod +x /setup-container.sh
1725
RUN /setup-container.sh
@@ -25,12 +33,10 @@ RUN chmod +x /start.sh
2533
ENTRYPOINT ["/entrypoint.sh"]
2634
CMD ["/start.sh"]
2735

28-
COPY ./devops/compose/production/django/setup-project.sh /
29-
COPY pyproject.toml .
30-
COPY poetry.lock .
31-
COPY README.md .
32-
RUN chmod +x /setup-project.sh
33-
RUN /setup-project.sh
36+
RUN --mount=type=cache,target=/root/.cache/uv \
37+
--mount=type=bind,source=uv.lock,target=uv.lock \
38+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
39+
uv sync --locked --no-install-project --dev
3440

3541
COPY ./devops/compose/production/django/setup-django.sh /
3642
RUN chmod +x /setup-django.sh

Diff for: devops/compose/local/docs/Dockerfile

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ENV PYTHONUNBUFFERED 1
55
ENV PYTHONDONTWRITEBYTECODE 1
66

77
RUN apt-get update && apt-get install --no-install-recommends -y \
8+
git \
89
# To run the Makefile
910
make \
1011
# Translations dependencies
@@ -19,12 +20,11 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
1920
&& rm -rf /var/lib/apt/lists/*
2021

2122
# Install Python dependencies
22-
COPY pyproject.toml .
23-
COPY poetry.lock .
24-
RUN pip install -U pip && \
25-
pip install poetry==1.8.2 && \
26-
poetry config virtualenvs.create false && \
27-
poetry install --with dev --with typing --with doc
23+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
24+
RUN --mount=type=cache,target=/root/.cache/uv \
25+
--mount=type=bind,source=uv.lock,target=uv.lock \
26+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
27+
uv sync --locked --no-install-project --dev --group doc
2828

2929
COPY ./devops/compose/local/docs/start.sh /start-docs.sh
3030
RUN chmod +x /start-docs.sh

Diff for: devops/compose/local/docs/start.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ set -o errexit
44
set -o pipefail
55
set -o nounset
66

7-
exec make livehtml
7+
exec uv run make livehtml

0 commit comments

Comments
 (0)