Skip to content

Commit 3b2065a

Browse files
committed
Switch to uv
1 parent e23c119 commit 3b2065a

File tree

10 files changed

+825
-218
lines changed

10 files changed

+825
-218
lines changed

.github/workflows/python-tests.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,11 @@ jobs:
1111
uses: actions/checkout@v4
1212

1313
- name: Set up Python
14-
uses: actions/setup-python@v5
15-
with:
16-
python-version: "3.13"
17-
cache: "pip"
18-
cache-dependency-path: requirements.*.txt
19-
20-
- name: Install Python dependencies
21-
run: |
22-
python -m pip install --upgrade pip
23-
pip install -r requirements.prod.txt -r requirements.dev.txt
14+
uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
2415

2516
- name: Run pre-commit
2617
run: |
27-
pre-commit run --all-files --show-diff-on-failure
18+
uv run pre-commit run --all-files --show-diff-on-failure
2819
2920
- name: Run Python tests
3021
run: |

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

CONTRIBUTING.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,28 @@ Set up a virtualenv and run:
2626
This will install the requirements, collect static files, migrate the database, and finally load all the existing fixtures into your database.
2727

2828
## Updating requirements
29-
Add or remove the dependency from either `requirements.prod.in` or `requirements.dev.in` as appropriate.
29+
Add a dependency with:
3030

31-
Run `make compile` and appropriate txt file will be updated.
31+
uv add [--dev] <dependency>
32+
33+
Remove a dependency with:
34+
35+
uv remove [--dev] <dependency>
36+
37+
Update a single dependency with:
38+
39+
uv add [--dev] --upgrade-package <dependency>
3240

3341
## Add data for new versions of Django
34-
1. Update the `requirements.prod.in` file to pin the new version of Django, eg `django==5.1`
35-
1. Run `make compile` to compile this change to `requirements.prod.txt`
36-
1. Run `python manage.py populate_cbv` to introspect the installed Django and populate the required objects in the database
37-
1. Run `python manage.py fetch_docs_urls` to update the records in the database with the latest links to the Django documentation, this will fail at 1.9, this is expected
38-
1. Export the new Django version into a fixture with `python manage.py cbv_dumpversion x.xx > cbv/fixtures/x.xx.json`
39-
1. Remove the empty Generic module from the generated JSON
40-
1. Add the fixture to git with `git add cbv/fixtures/<version>.git`
41-
1. Restore the requirements files with `git restore requirements.*`
42-
1. Commit and push your changes, they will be deployed once your PR is merged to main
42+
1. Update Django with `uv add --upgrade-package django<N`, replacing `N` with
43+
the version **after** the one you are updating to
44+
1. Update the project's code to run under the target version of Django, as
45+
necessary;
46+
1. Use `uv run manage.py populate_cbv` to introspect the running Django
47+
and populate the required objects in the database;
48+
1. Use `uv run manage.py fetch_docs_urls` to update the records in the
49+
database with the latest links to the Django documentation;
50+
1. Export the new Django version into a fixture with: `uv run manage.py cbv_dumpversion x.xx > cbv/fixtures/x.xx.json`;
4351

4452
## Testing
4553
Run `make test` to run the full test suite with coverage.

Makefile

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,24 @@ help:
44
@echo " make test: runs the tests."
55
@echo " make build: install as for a deployed environment."
66
@echo " make run-prod: run webserver as in deployed environment."
7-
@echo " make compile: compile the requirements specs."
8-
9-
_uv:
10-
# ensure uv is installed
11-
pip install uv
127

138
test:
14-
coverage run -m pytest -vvv tests
15-
coverage report
9+
uv run coverage run -m pytest -vvv tests
10+
uv run coverage report
1611

1712
mypy:
18-
mypy . | mypy-json-report > mypy-ratchet.json
13+
uv run mypy . | uv run mypy-json-report > mypy-ratchet.json
1914
git diff --exit-code mypy-ratchet.json
2015

21-
build: _uv
22-
uv pip install -r requirements.prod.txt -r requirements.dev.txt
23-
rm -rf staticfiles/*
24-
python manage.py collectstatic --no-input
16+
build:
17+
uv run manage.py collectstatic --no-input
2518
rm -f ccbv.sqlite
26-
python manage.py migrate
27-
python manage.py load_all_django_versions
19+
uv run manage.py migrate
20+
uv run manage.py load_all_django_versions
2821

2922
build-prod:
30-
pip install -r requirements.prod.txt
3123
rm -rf staticfiles/*
32-
python manage.py collectstatic --no-input
33-
rm -f ccbv.sqlite
34-
python manage.py migrate
35-
python manage.py load_all_django_versions
24+
uv run manage.py collectstatic --no-input
3625

3726
run-prod:
3827
gunicorn core.wsgi --log-file -
39-
40-
compile: _uv
41-
uv pip compile --quiet requirements.prod.in --output-file=requirements.prod.txt
42-
uv pip compile --quiet requirements.dev.in --output-file=requirements.dev.txt

pyproject.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
[project]
2+
name = "ccbv"
3+
version = "1.0.0"
4+
description = "Tool to view class hierarchies"
5+
requires-python = ">=3.13"
6+
dependencies = [
7+
"attrs>=21.4.0",
8+
"blessings>=1.7",
9+
"django~=5.2",
10+
"django-extensions>=3.1.3",
11+
"django-pygmy>=0.1.5",
12+
"django-sans-db>=1.2.0",
13+
"environs[django]>=14.1.1",
14+
"gunicorn>=20.1.0",
15+
"requests>=2.32.3",
16+
"sphinx>=8.1.3",
17+
"werkzeug>=2.0.2",
18+
"whitenoise>=6.9.0",
19+
]
20+
21+
[dependency-groups]
22+
dev = [
23+
"coverage[toml]>=6.5.0",
24+
"factory-boy>=3.2.0",
25+
"mypy>=1.15.0",
26+
"mypy-json-report>=0.1.3",
27+
"pre-commit>=4.2.0",
28+
"pytest>=8.3.5",
29+
"pytest-django>=4.5.2",
30+
"types-requests>=2.27.7",
31+
]
32+
133
[tool.coverage.run]
234
branch = true
335
dynamic_context = "test_function"

requirements.dev.in

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

requirements.dev.txt

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

requirements.prod.in

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

requirements.prod.txt

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

0 commit comments

Comments
 (0)