Skip to content

Switch to uv #250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,11 @@ jobs:
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pip"
cache-dependency-path: requirements.*.txt

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.prod.txt -r requirements.dev.txt
uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2

- name: Run pre-commit
run: |
pre-commit run --all-files --show-diff-on-failure
uv run pre-commit run --all-files --show-diff-on-failure

- name: Run Python tests
run: |
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10
24 changes: 7 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,20 @@ help:
@echo " make test: runs the tests."
@echo " make build: install as for a deployed environment."
@echo " make run-prod: run webserver as in deployed environment."
@echo " make compile: compile the requirements specs."

_uv:
# ensure uv is installed
pip install uv

test:
coverage run -m pytest -vvv
coverage report
uv run coverage run -m pytest -vvv
uv run coverage report

mypy:
mypy . | mypy-json-report > mypy-ratchet.json
uv run mypy . | uv run mypy-json-report > mypy-ratchet.json
git diff --exit-code mypy-ratchet.json

build: _uv
uv pip install -r requirements.prod.txt -r requirements.dev.txt
python manage.py collectstatic --no-input
build:
uv run manage.py collectstatic --no-input
rm -f ccbv.sqlite
python manage.py migrate
python manage.py load_all_django_versions
uv run manage.py migrate
uv run manage.py load_all_django_versions

run-prod:
gunicorn core.wsgi --log-file -

compile: _uv
uv pip compile requirements.prod.in --output-file=requirements.prod.txt
uv pip compile requirements.dev.in --output-file=requirements.dev.txt
38 changes: 22 additions & 16 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -52,51 +52,57 @@ e.g. (inside your virtualenv or whatever)

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

python manage.py migrate cbv
uv run manage.py migrate cbv

Populate the database with fixtures, either all at once:

python manage.py load_all_django_versions
uv run manage.py load_all_django_versions

or one at a time, for example:

python manage.py loaddata cbv/fixtures/1.8.json
python manage.py loaddata cbv/fixtures/1.9.json
uv run manage.py loaddata cbv/fixtures/1.8.json
uv run manage.py loaddata cbv/fixtures/1.9.json

Collect static files (CSS & JS)

python manage.py collectstatic
uv run manage.py collectstatic

Run server and play around

python manage.py runserver
uv run manage.py runserver

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

pre-commit install


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

Run `make compile` and appropriate txt file will be updated.
uv add [--dev] <dependency>

Remove a dependency with:

uv remove [--dev] <dependency>

Update a single dependency with:

uv add [--dev] --upgrade-package <dependency>


## Updating for New Versions of Django

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

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


## Testing
Expand Down
35 changes: 35 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
[project]
name = "ccbv"
version = "1.0.0"
description = "Tool to view class hierarchies"
requires-python = ">=3.10"
dependencies = [
"attrs>=21.4.0",
"blessings>=1.7",
"django~=3.1.14",
"django-extensions>=3.1.3",
"django-pygmy>=0.1.5",
"django-sans-db>=1.2.0",
"environs[django]>=9.5.0",
"gunicorn>=20.1.0",
"requests>=2.32.3",
"sphinx>=8.1.3",
"werkzeug>=2.0.2",
"whitenoise>=5.3.0",
]

[dependency-groups]
dev = [
"coverage[toml]>=6.5.0",
"factory-boy>=3.2.0",
"mypy>=0.931",
"mypy-json-report>=0.1.3",
"pre-commit>=2.15.0",
"pytest>=7.1.2",
"pytest-django>=4.5.2",
"types-requests>=2.27.7",
]

[tool.coverage.run]
branch = true
dynamic_context = "test_function"
Expand Down Expand Up @@ -54,3 +86,6 @@ extend-ignore = [

[tool.ruff.lint.isort]
lines-after-imports = 2

[tool.uv]
required-version = ">=0.6.16"
11 changes: 0 additions & 11 deletions requirements.dev.in

This file was deleted.

83 changes: 0 additions & 83 deletions requirements.dev.txt

This file was deleted.

13 changes: 0 additions & 13 deletions requirements.prod.in

This file was deleted.

70 changes: 0 additions & 70 deletions requirements.prod.txt

This file was deleted.

Loading