Skip to content

Commit a52e293

Browse files
committed
Switch to uv
1 parent e31ddae commit a52e293

File tree

10 files changed

+956
-237
lines changed

10 files changed

+956
-237
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@v3
1212

1313
- name: Set up Python
14-
uses: actions/setup-python@v4
15-
with:
16-
python-version: "3.10"
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.10

Makefile

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,20 @@ 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
15-
coverage report
9+
uv run coverage run -m pytest -vvv
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-
python manage.py collectstatic --no-input
16+
build:
17+
uv run manage.py collectstatic --no-input
2418
rm -f ccbv.sqlite
25-
python manage.py migrate
26-
python manage.py load_all_django_versions
19+
uv run manage.py migrate
20+
uv run manage.py load_all_django_versions
2721

2822
run-prod:
2923
gunicorn core.wsgi --log-file -
30-
31-
compile: _uv
32-
uv pip compile requirements.prod.in --output-file=requirements.prod.txt
33-
uv pip compile requirements.dev.in --output-file=requirements.dev.txt

README.markdown

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,51 +52,57 @@ e.g. (inside your virtualenv or whatever)
5252

5353
Prepare the database (assuming you've got required database)
5454

55-
python manage.py migrate cbv
55+
uv run manage.py migrate cbv
5656

5757
Populate the database with fixtures, either all at once:
5858

59-
python manage.py load_all_django_versions
59+
uv run manage.py load_all_django_versions
6060

6161
or one at a time, for example:
6262

63-
python manage.py loaddata cbv/fixtures/1.8.json
64-
python manage.py loaddata cbv/fixtures/1.9.json
63+
uv run manage.py loaddata cbv/fixtures/1.8.json
64+
uv run manage.py loaddata cbv/fixtures/1.9.json
6565

6666
Collect static files (CSS & JS)
6767

68-
python manage.py collectstatic
68+
uv run manage.py collectstatic
6969

7070
Run server and play around
7171

72-
python manage.py runserver
72+
uv run manage.py runserver
7373

7474
If you hope to contribute any code, please install `pre-commit` before committing.
7575

7676
pre-commit install
7777

7878

7979
## Updating Requirements
80-
Add or remove the dependency from either `requirements.prod.in` or `requirements.dev.in` as appropriate.
80+
Add a dependency with:
8181

82-
Run `make compile` and appropriate txt file will be updated.
82+
uv add [--dev] <dependency>
83+
84+
Remove a dependency with:
85+
86+
uv remove [--dev] <dependency>
87+
88+
Update a single dependency with:
89+
90+
uv add [--dev] --upgrade-package <dependency>
8391

8492

8593
## Updating for New Versions of Django
8694

8795
The procedure for updating for a new version of Django is as simple as:
8896

89-
1. Update the `requirements.in` file to pin the required version of Django;
90-
2. Use `pip-compile` to freshen requirements for the new version of Django;
91-
3. Use `pip-sync` to update your virtual environment to match the newly compiled
92-
`requirements.txt` file;
93-
4. Update the project's code to run under the target version of Django, as
97+
1. Update Django with `uv add --upgrade-package django<N`, replacing `N` with
98+
the version **after** the one you are updating to
99+
1. Update the project's code to run under the target version of Django, as
94100
necessary;
95-
5. Use `python manage.py populate_cbv` to introspect the running Django
101+
1. Use `uv run manage.py populate_cbv` to introspect the running Django
96102
and populate the required objects in the database;
97-
6. Use `python manage.py fetch_docs_urls` to update the records in the
103+
1. Use `uv run manage.py fetch_docs_urls` to update the records in the
98104
database with the latest links to the Django documentation;
99-
7. Export the new Django version into a fixture with: `python manage.py cbv_dumpversion x.xx > cbv/fixtures/x.xx.json`;
105+
1. Export the new Django version into a fixture with: `uv run manage.py cbv_dumpversion x.xx > cbv/fixtures/x.xx.json`;
100106

101107

102108
## Testing

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.10"
6+
dependencies = [
7+
"attrs>=21.4.0",
8+
"blessings>=1.7",
9+
"django~=3.1.14",
10+
"django-extensions>=3.1.3",
11+
"django-pygmy>=0.1.5",
12+
"django-sans-db>=1.2.0",
13+
"environs[django]>=9.5.0",
14+
"gunicorn>=20.1.0",
15+
"requests>=2.32.3",
16+
"sphinx>=8.1.3",
17+
"werkzeug>=2.0.2",
18+
"whitenoise>=5.3.0",
19+
]
20+
21+
[dependency-groups]
22+
dev = [
23+
"coverage[toml]>=6.5.0",
24+
"factory-boy>=3.2.0",
25+
"mypy>=0.931",
26+
"mypy-json-report>=0.1.3",
27+
"pre-commit>=2.15.0",
28+
"pytest>=7.1.2",
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 & 77 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 & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)