Skip to content

Commit

Permalink
Merge pull request #237 from classy-python/split-dependencies
Browse files Browse the repository at this point in the history
Split dependencies
  • Loading branch information
meshy authored Jun 2, 2024
2 parents be2107c + 14a5126 commit d68ae31
Show file tree
Hide file tree
Showing 8 changed files with 183 additions and 166 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ jobs:
with:
python-version: "3.10"
cache: "pip"
cache-dependency-path: requirements.txt
cache-dependency-path: requirements.*.txt

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements.prod.txt -r requirements.dev.txt
- name: Run pre-commit
run: |
Expand Down
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ 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
Expand All @@ -13,12 +18,16 @@ mypy:
mypy . | mypy-json-report > mypy-ratchet.json
git diff --exit-code mypy-ratchet.json

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

run-prod:
DATABASE_URL=sqlite:///ccbv.sqlite 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
9 changes: 4 additions & 5 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ First you should install some OS libraries required for some packages, this can

sudo apt-get install python3-dev libmemcached-dev zlib1g-dev libpq-dev

After this, install as you normally would a Django site (requirements.txt provided).
After this, install as you normally would a Django site (requirements files are provided).

e.g. (inside your virtualenv or whatever)

pip install -r requirements.txt
[uv] pip install -r requirements.prod.txt -r requirements.dev.txt

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

Expand Down Expand Up @@ -77,10 +77,9 @@ If you hope to contribute any code, please install `pre-commit` before committin


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

Run `pip-compile` and `requirements.txt` will be updated based on the specs in `requirements.in`.

More details can be found on the [pip-tools](https://github.com/nvie/pip-tools) website.
Run `make compile` and appropriate txt file will be updated.


## Updating for New Versions of Django
Expand Down
11 changes: 11 additions & 0 deletions requirements.dev.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--constraint requirements.prod.txt

coverage[toml]
factory_boy
mypy
mypy-json-report>=0.1.3
pre-commit
pytest
pytest-django
pytest-subtests
types-requests
83 changes: 83 additions & 0 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# This file was autogenerated by uv via the following command:
# uv pip compile requirements.dev.in --output-file=requirements.dev.txt
attrs==21.4.0
# via
# -c requirements.prod.txt
# pytest
backports-entry-points-selectable==1.2.0
# via virtualenv
cfgv==3.3.1
# via pre-commit
coverage==6.5.0
# via -r requirements.dev.in
distlib==0.3.3
# via virtualenv
factory-boy==3.2.0
# via -r requirements.dev.in
faker==9.3.1
# via factory-boy
filelock==3.3.0
# via virtualenv
identify==2.3.0
# via pre-commit
iniconfig==1.1.1
# via pytest
mypy==0.931
# via -r requirements.dev.in
mypy-extensions==0.4.3
# via mypy
mypy-json-report==0.1.3
# via -r requirements.dev.in
nodeenv==1.6.0
# via pre-commit
packaging==21.3
# via
# -c requirements.prod.txt
# pytest
platformdirs==2.4.0
# via virtualenv
pluggy==1.0.0
# via pytest
pre-commit==2.15.0
# via -r requirements.dev.in
py==1.11.0
# via pytest
pyparsing==3.0.6
# via
# -c requirements.prod.txt
# packaging
pytest==7.1.2
# via
# -r requirements.dev.in
# pytest-django
# pytest-subtests
pytest-django==4.5.2
# via -r requirements.dev.in
pytest-subtests==0.8.0
# via -r requirements.dev.in
python-dateutil==2.8.2
# via faker
pyyaml==6.0.1
# via pre-commit
six==1.16.0
# via
# -c requirements.prod.txt
# python-dateutil
# virtualenv
text-unidecode==1.3
# via faker
toml==0.10.2
# via pre-commit
tomli==2.0.0
# via
# coverage
# mypy
# pytest
types-requests==2.27.7
# via -r requirements.dev.in
types-urllib3==1.26.7
# via types-requests
typing-extensions==4.0.1
# via mypy
virtualenv==20.8.1
# via pre-commit
9 changes: 0 additions & 9 deletions requirements.in → requirements.prod.in
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
attrs>=21.4.0
blessings
coverage[toml]
django~=3.1.14
django-extensions
django-pygmy
django-sans-db>=1.2.0
environs[django]
factory_boy
gunicorn
mypy
mypy-json-report>=0.1.3
pre-commit
psycopg2-binary>=2.9.5
pytest
pytest-django
pytest-subtests
requests
# New versions aren't supported yet
sphinx==1.2.2
types-requests
werkzeug
whitenoise
72 changes: 72 additions & 0 deletions requirements.prod.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# This file was autogenerated by uv via the following command:
# uv pip compile requirements.prod.in --output-file=requirements.prod.txt
asgiref==3.4.1
# via django
attrs==21.4.0
# via -r requirements.prod.in
blessings==1.7
# via -r requirements.prod.in
certifi==2022.12.7
# via requests
charset-normalizer==2.0.7
# via requests
dj-database-url==0.5.0
# via environs
dj-email-url==1.0.6
# via environs
django==3.1.14
# via
# -r requirements.prod.in
# django-extensions
django-cache-url==3.4.2
# via environs
django-extensions==3.1.3
# via -r requirements.prod.in
django-pygmy==0.1.5
# via -r requirements.prod.in
django-sans-db==1.2.0
# via -r requirements.prod.in
docutils==0.17.1
# via sphinx
environs==9.5.0
# via -r requirements.prod.in
gunicorn==20.1.0
# via -r requirements.prod.in
idna==3.3
# via requests
jinja2==3.0.2
# via sphinx
markupsafe==2.0.1
# via jinja2
marshmallow==3.18.0
# via environs
packaging==21.3
# via marshmallow
psycopg2-binary==2.9.5
# via -r requirements.prod.in
pygments==2.10.0
# via
# django-pygmy
# sphinx
pyparsing==3.0.6
# via packaging
python-dotenv==0.21.0
# via environs
pytz==2021.3
# via django
requests==2.26.0
# via -r requirements.prod.in
setuptools==70.0.0
# via gunicorn
six==1.16.0
# via blessings
sphinx==1.2.2
# via -r requirements.prod.in
sqlparse==0.4.2
# via django
urllib3==1.26.7
# via requests
werkzeug==2.0.2
# via -r requirements.prod.in
whitenoise==5.3.0
# via -r requirements.prod.in
Loading

0 comments on commit d68ae31

Please sign in to comment.