Skip to content
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

Split dependencies based on required use #30

Merged
merged 10 commits into from
May 9, 2024
Merged
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: 7 additions & 6 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ jobs:
runs-on: ubuntu-22.04
timeout-minutes: 3

strategy:
matrix:
python-version: ["3.10"]

steps:
- name: Clone the code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: "3.10"
cache: 'pip'
cache-dependency-path: |
pyproject.toml
requirements/*.txt
tox.ini

- name: Install requirements
run: make install
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/release-to-pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
cache-dependency-path: |
pyproject.toml
requirements/*.txt
tox.ini

- name: Install requirements
run: make install
run: pip install --requirement requirements/release.txt

- name: Verify version
run: ./scripts/verify-version-tag.py
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ jobs:
3.11
3.10
cache: 'pip'
cache-dependency-path: |
pyproject.toml
requirements/*.txt
tox.ini

- name: Install tox
run: pip install tox
run: pip install -r requirements/tox.txt

- name: Run the tests
run: tox --parallel --parallel-no-spinner --skip-missing-interpreters=false
Expand Down
14 changes: 2 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,7 @@ Ensure that a supported version of PostgreSQL (see README) is installed and runn

### Installing Python dependencies

> [!NOTE]
> You might not need to install the below requirements if you only intend to run the tests,
> because we use [tox] for the tests, and it manages the installation of dependencies.

If you only intend to run the tests with [tox], then you may only require:

```sh
pip install tox
```

Alternatively, to install all the development dependencies in your virtual environment, run:
To install all the development dependencies in your virtual environment, run:

```sh
make install
Expand All @@ -58,7 +48,7 @@ Alternatively, if you want to run the tests directly in your virtual environment
you many run the tests with:

```sh
python3 -m pytest
PYTHONPATH=src python3 -m pytest
```

### Static analysis
Expand Down
28 changes: 21 additions & 7 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ help:
@echo " update: Update dev dependencies"
@echo " test: Run Python tests"
@echo " lint: Run formatters and static analysis checks"
@echo " package: Build a wheel package"


# Standard entry points
Expand All @@ -27,11 +26,23 @@ lint: format style typing

.PHONY:update
update:
pip-compile pyproject.toml --quiet --upgrade --resolver=backtracking --extra=dev --output-file=requirements/development.txt --unsafe-package django

.PHONY:package
package:
pip wheel .
pip-compile pyproject.toml \
--quiet --upgrade --resolver=backtracking --strip-extras \
--extra=dev \
--output-file=requirements/development.txt
pip-compile pyproject.toml \
--quiet --upgrade --resolver=backtracking --strip-extras \
--extra=pytest-in-tox \
--output-file=requirements/pytest-in-tox.txt \
--unsafe-package django
pip-compile pyproject.toml \
--quiet --upgrade --resolver=backtracking --strip-extras \
--extra=release \
--output-file=requirements/release.txt
pip-compile pyproject.toml \
--quiet --upgrade --resolver=backtracking --strip-extras \
--extra=tox \
--output-file=requirements/tox.txt


# Implementation details
Expand All @@ -48,7 +59,10 @@ install_prerequisites: requirements/prerequisites.txt

# Add new dependencies to requirements/development.txt whenever pyproject.toml changes
requirements/development.txt: pyproject.toml
pip-compile pyproject.toml --quiet --resolver=backtracking --extra=dev --output-file=requirements/development.txt --unsafe-package django
pip-compile pyproject.toml \
--quiet --resolver=backtracking --strip-extras \
--extra=dev \
--output-file=requirements/development.txt

.PHONY:format
format:
Expand Down
33 changes: 32 additions & 1 deletion mypy-ratchet.json
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
{}
{
"scripts/verify-version-tag.py": {
"Function is missing a return type annotation [no-untyped-def]": 1
},
"src/django_integrity/constraints.py": {
"Cannot find implementation or library stub for module named \"psycopg\" [import-not-found]": 1,
"Library stubs not installed for \"psycopg2\" [import-untyped]": 1,
"Module has no attribute \"transaction\" [attr-defined]": 4
},
"src/django_integrity/conversion.py": {
"Cannot find implementation or library stub for module named \"psycopg\" [import-not-found]": 1,
"Function is missing a return type annotation [no-untyped-def]": 1,
"Library stubs not installed for \"psycopg2\" [import-untyped]": 1,
"Returning Any from function declared to return \"bool\" [no-any-return]": 2
},
"tests/django_integrity/test_constraints.py": {
"Function is missing a return type annotation [no-untyped-def]": 13
},
"tests/django_integrity/test_conversion.py": {
"Argument \"fields\" to \"Unique\" has incompatible type \"tuple[str, str]\"; expected \"tuple[str]\" [arg-type]": 1,
"Argument \"model\" to \"Unique\" has incompatible type \"Unique\"; expected \"type[Model]\" [arg-type]": 1,
"Argument 1 to \"refine_integrity_error\" has incompatible type \"dict[ForeignKey, type[SimpleError]]\"; expected \"Mapping[_Rule, Exception]\" [arg-type]": 3,
"Argument 1 to \"refine_integrity_error\" has incompatible type \"dict[Named, type[SimpleError]]\"; expected \"Mapping[_Rule, Exception]\" [arg-type]": 2,
"Argument 1 to \"refine_integrity_error\" has incompatible type \"dict[NotNull, type[SimpleError]]\"; expected \"Mapping[_Rule, Exception]\" [arg-type]": 3,
"Argument 1 to \"refine_integrity_error\" has incompatible type \"dict[PrimaryKey, type[SimpleError]]\"; expected \"Mapping[_Rule, Exception]\" [arg-type]": 2,
"Argument 1 to \"refine_integrity_error\" has incompatible type \"dict[Unique, type[SimpleError]]\"; expected \"Mapping[_Rule, Exception]\" [arg-type]": 3,
"Function is missing a return type annotation [no-untyped-def]": 14,
"Function is missing a type annotation [no-untyped-def]": 1,
"Incompatible type for \"unique_field\" of \"AlternativeUniqueModel\" (got \"None\", expected \"float | int | str | Combinable\") [misc]": 1,
"Incompatible type for \"unique_field\" of \"UniqueModel\" (got \"None\", expected \"float | int | str | Combinable\") [misc]": 2
}
}
22 changes: 22 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,33 @@ repository = "https://github.com/octoenergy/django-integrity"
changelog = "https://github.com/octoenergy/django-integrity/blob/main/CHANGELOG.md"

[project.optional-dependencies]
# None of these extras are recommended for normal installation.
# We use combinations of these groups in development and testing environments.
pytest-in-tox = [
# We deliberately exclude Django and Psycopg from this list because
# this groups is used for running the pytest tests with tox,
# and those packages are a part of tox's test matrix.
"dj-database-url",
"django-stubs",
"environs",
"pytest",
"pytest-django",
]
release = [
"rich",
"tomli >= 1.1.0 ; python_version < '3.11'",
"typer",
]
tox = [
"tox",
]
dev = [
# Testing
"dj-database-url",
"django",
"django-stubs",
"environs",
"psycopg2-binary",
"pytest",
"pytest-django",
"tox",
Expand Down
13 changes: 9 additions & 4 deletions requirements/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --extra=dev --output-file=requirements/development.txt --unsafe-package=django pyproject.toml
# pip-compile --extra=dev --output-file=requirements/development.txt --strip-extras pyproject.toml
#
asgiref==3.8.1
# via
Expand All @@ -20,6 +20,12 @@ distlib==0.3.8
# via virtualenv
dj-database-url==2.1.0
# via django_integrity (pyproject.toml)
django==5.0.6
# via
# dj-database-url
# django-stubs
# django-stubs-ext
# django_integrity (pyproject.toml)
django-stubs==5.0.0
# via django_integrity (pyproject.toml)
django-stubs-ext==5.0.0
Expand Down Expand Up @@ -60,6 +66,8 @@ pluggy==1.5.0
# via
# pytest
# tox
psycopg2-binary==2.9.9
# via django_integrity (pyproject.toml)
pygments==2.18.0
# via rich
pyproject-api==1.6.1
Expand Down Expand Up @@ -106,6 +114,3 @@ typing-extensions==4.11.0
# typer
virtualenv==20.26.1
# via tox

# The following packages are considered to be unsafe in a requirements file:
# django
55 changes: 55 additions & 0 deletions requirements/pytest-in-tox.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --extra=pytest-in-tox --output-file=requirements/pytest-in-tox.txt --strip-extras --unsafe-package=django pyproject.toml
#
asgiref==3.8.1
# via
# django
# django-stubs
dj-database-url==2.1.0
# via django_integrity (pyproject.toml)
django-stubs==5.0.0
# via django_integrity (pyproject.toml)
django-stubs-ext==5.0.0
# via django-stubs
environs==11.0.0
# via django_integrity (pyproject.toml)
exceptiongroup==1.2.1
# via pytest
iniconfig==2.0.0
# via pytest
marshmallow==3.21.2
# via environs
packaging==24.0
# via
# marshmallow
# pytest
pluggy==1.5.0
# via pytest
pytest==8.2.0
# via
# django_integrity (pyproject.toml)
# pytest-django
pytest-django==4.8.0
# via django_integrity (pyproject.toml)
python-dotenv==1.0.1
# via environs
sqlparse==0.5.0
# via django
tomli==2.0.1
# via
# django-stubs
# pytest
types-pyyaml==6.0.12.20240311
# via django-stubs
typing-extensions==4.11.0
# via
# asgiref
# dj-database-url
# django-stubs
# django-stubs-ext

# The following packages are considered to be unsafe in a requirements file:
# django
26 changes: 26 additions & 0 deletions requirements/release.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --extra=release --output-file=requirements/release.txt --strip-extras pyproject.toml
#
click==8.1.7
# via typer
markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
pygments==2.18.0
# via rich
rich==13.7.1
# via
# django_integrity (pyproject.toml)
# typer
shellingham==1.5.4
# via typer
tomli==2.0.1 ; python_version < "3.11"
# via django_integrity (pyproject.toml)
typer==0.12.3
# via django_integrity (pyproject.toml)
typing-extensions==4.11.0
# via typer
38 changes: 38 additions & 0 deletions requirements/tox.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --extra=tox --output-file=requirements/tox.txt --strip-extras pyproject.toml
#
cachetools==5.3.3
# via tox
chardet==5.2.0
# via tox
colorama==0.4.6
# via tox
distlib==0.3.8
# via virtualenv
filelock==3.14.0
# via
# tox
# virtualenv
packaging==24.0
# via
# pyproject-api
# tox
platformdirs==4.2.1
# via
# tox
# virtualenv
pluggy==1.5.0
# via tox
pyproject-api==1.6.1
# via tox
tomli==2.0.1
# via
# pyproject-api
# tox
tox==4.15.0
# via django_integrity (pyproject.toml)
virtualenv==20.26.1
# via tox
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ env_list =
pass_env =
DATABASE_URL
deps =
-r requirements/development.txt
-r requirements/pytest-in-tox.txt
django41: django>=4.1,<4.2
django42: django>=4.2,<5.0
django50: django>=5.0,<5.1
Expand Down
Loading