From 59f9fb85732d9443dbad6f1e540a0233e9dc9c18 Mon Sep 17 00:00:00 2001 From: Fstei Date: Thu, 26 Sep 2024 08:36:09 +0200 Subject: [PATCH] Move optional dependencies from `dev_requirements` to `pyproject.toml` --- .github/workflows/formatting.yml | 2 +- .github/workflows/python-publish.yml | 8 ++- dev_requirements/requirements-coverage.in | 2 - dev_requirements/requirements-coverage.txt | 9 --- dev_requirements/requirements-formatting.in | 3 - dev_requirements/requirements-formatting.txt | 21 ------ dev_requirements/requirements-linting.in | 2 - dev_requirements/requirements-linting.txt | 21 ------ dev_requirements/requirements-packaging.in | 3 - dev_requirements/requirements-packaging.txt | 74 -------------------- dev_requirements/requirements-tests.in | 3 - dev_requirements/requirements-tests.txt | 25 ------- dev_requirements/requirements-type_check.in | 2 - dev_requirements/requirements-type_check.txt | 13 ---- pyproject.toml | 26 +++++++ tox.ini | 14 ++-- 16 files changed, 40 insertions(+), 188 deletions(-) delete mode 100644 dev_requirements/requirements-coverage.in delete mode 100644 dev_requirements/requirements-coverage.txt delete mode 100644 dev_requirements/requirements-formatting.in delete mode 100644 dev_requirements/requirements-formatting.txt delete mode 100644 dev_requirements/requirements-linting.in delete mode 100644 dev_requirements/requirements-linting.txt delete mode 100644 dev_requirements/requirements-packaging.in delete mode 100644 dev_requirements/requirements-packaging.txt delete mode 100644 dev_requirements/requirements-tests.in delete mode 100644 dev_requirements/requirements-tests.txt delete mode 100644 dev_requirements/requirements-type_check.in delete mode 100644 dev_requirements/requirements-type_check.txt diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml index 9dfedc7..67b5112 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/formatting.yml @@ -18,7 +18,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r dev_requirements/requirements-formatting.txt + pip install .[formatting] - name: ${{ matrix.tool }} Code Formatter run: | ${{ matrix.tool }} . --check diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 3dd0653..ccc981d 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -35,7 +35,11 @@ jobs: build-n-publish: name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: [ "3.12" ] + os: [ ubuntu-latest ] # Specifying a GitHub environment, # Specifying a GitHub environment, which is strongly recommended by PyPI: https://docs.pypi.org/trusted-publishers/adding-a-publisher/ # you have to create an environment in your repository settings and add the environment name here environment: release @@ -52,7 +56,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r dev_requirements/requirements-packaging.txt + pip install .[test_packaging] - name: Build wheel and source distributions run: | python -m build diff --git a/dev_requirements/requirements-coverage.in b/dev_requirements/requirements-coverage.in deleted file mode 100644 index d1e1a80..0000000 --- a/dev_requirements/requirements-coverage.in +++ /dev/null @@ -1,2 +0,0 @@ -# specific requirements for the tox coverage env -coverage diff --git a/dev_requirements/requirements-coverage.txt b/dev_requirements/requirements-coverage.txt deleted file mode 100644 index c481bea..0000000 --- a/dev_requirements/requirements-coverage.txt +++ /dev/null @@ -1,9 +0,0 @@ -# SHA1:6dafbcf610e9f81897b65ee9142715ab2e793f9e -# -# This file is autogenerated by pip-compile-multi -# To update, run: -# -# pip-compile-multi -# -coverage==7.6.1 - # via -r dev_requirements/requirements-coverage.in diff --git a/dev_requirements/requirements-formatting.in b/dev_requirements/requirements-formatting.in deleted file mode 100644 index 41e6b86..0000000 --- a/dev_requirements/requirements-formatting.in +++ /dev/null @@ -1,3 +0,0 @@ -# specific requirements for the formatting envs -black -isort diff --git a/dev_requirements/requirements-formatting.txt b/dev_requirements/requirements-formatting.txt deleted file mode 100644 index 65cfe82..0000000 --- a/dev_requirements/requirements-formatting.txt +++ /dev/null @@ -1,21 +0,0 @@ -# SHA1:2c7ffcd29222de3114c7f7994911f1b69d06b6b3 -# -# This file is autogenerated by pip-compile-multi -# To update, run: -# -# pip-compile-multi -# -black==24.8.0 - # via -r dev_requirements/requirements-formatting.in -click==8.1.7 - # via black -isort==5.13.2 - # via -r dev_requirements/requirements-formatting.in -mypy-extensions==1.0.0 - # via black -packaging==24.0 - # via black -pathspec==0.12.1 - # via black -platformdirs==4.2.0 - # via black diff --git a/dev_requirements/requirements-linting.in b/dev_requirements/requirements-linting.in deleted file mode 100644 index 787ac85..0000000 --- a/dev_requirements/requirements-linting.in +++ /dev/null @@ -1,2 +0,0 @@ -# specific requirements for the tox linting env -pylint diff --git a/dev_requirements/requirements-linting.txt b/dev_requirements/requirements-linting.txt deleted file mode 100644 index bf6e37c..0000000 --- a/dev_requirements/requirements-linting.txt +++ /dev/null @@ -1,21 +0,0 @@ -# SHA1:0e15f8789b9d62fe90d1f1b0b6a7e32f13b99b19 -# -# This file is autogenerated by pip-compile-multi -# To update, run: -# -# pip-compile-multi -# -astroid==3.3.3 - # via pylint -dill==0.3.8 - # via pylint -isort==5.13.2 - # via pylint -mccabe==0.7.0 - # via pylint -platformdirs==4.2.0 - # via pylint -pylint==3.3.0 - # via -r dev_requirements/requirements-linting.in -tomlkit==0.12.4 - # via pylint diff --git a/dev_requirements/requirements-packaging.in b/dev_requirements/requirements-packaging.in deleted file mode 100644 index 3aad7fa..0000000 --- a/dev_requirements/requirements-packaging.in +++ /dev/null @@ -1,3 +0,0 @@ -# requirements for the hatchling build ssystem -build -twine diff --git a/dev_requirements/requirements-packaging.txt b/dev_requirements/requirements-packaging.txt deleted file mode 100644 index dffbdce..0000000 --- a/dev_requirements/requirements-packaging.txt +++ /dev/null @@ -1,74 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.12 -# by the following command: -# -# pip-compile dev_requirements/requirements-packaging.in -# -build==1.2.2 - # via -r dev_requirements/requirements-packaging.in -certifi==2024.2.2 - # via requests -cffi==1.16.0 - # via cryptography -charset-normalizer==3.3.2 - # via requests -cryptography==42.0.5 - # via secretstorage -docutils==0.20.1 - # via readme-renderer -idna==3.6 - # via requests -importlib-metadata==7.0.2 - # via - # keyring - # twine -jaraco-classes==3.3.1 - # via keyring -jeepney==0.8.0 - # via - # keyring - # secretstorage -keyring==24.3.1 - # via twine -markdown-it-py==3.0.0 - # via rich -mdurl==0.1.2 - # via markdown-it-py -more-itertools==10.2.0 - # via jaraco-classes -nh3==0.2.15 - # via readme-renderer -packaging==24.0 - # via build -pkginfo==1.10.0 - # via twine -pycparser==2.21 - # via cffi -pygments==2.17.2 - # via - # readme-renderer - # rich -pyproject-hooks==1.0.0 - # via build -readme-renderer==43.0 - # via twine -requests==2.31.0 - # via - # requests-toolbelt - # twine -requests-toolbelt==1.0.0 - # via twine -rfc3986==2.0.0 - # via twine -rich==13.7.1 - # via twine -secretstorage==3.3.3 - # via keyring -twine==5.1.1 - # via -r dev_requirements/requirements-packaging.in -urllib3==2.2.1 - # via - # requests - # twine -zipp==3.18.1 - # via importlib-metadata diff --git a/dev_requirements/requirements-tests.in b/dev_requirements/requirements-tests.in deleted file mode 100644 index c6b5420..0000000 --- a/dev_requirements/requirements-tests.in +++ /dev/null @@ -1,3 +0,0 @@ -# specific requirements for the tox tests env -pytest -pydantic diff --git a/dev_requirements/requirements-tests.txt b/dev_requirements/requirements-tests.txt deleted file mode 100644 index 4712736..0000000 --- a/dev_requirements/requirements-tests.txt +++ /dev/null @@ -1,25 +0,0 @@ -# SHA1:673b9994777b7b161bbe31039bb72e7cbb655db4 -# -# This file is autogenerated by pip-compile-multi -# To update, run: -# -# pip-compile-multi -# -annotated-types==0.6.0 - # via pydantic -iniconfig==2.0.0 - # via pytest -packaging==24.0 - # via pytest -pluggy==1.5.0 - # via pytest -pydantic==2.9.2 - # via -r dev_requirements/requirements-tests.in -pydantic-core==2.23.4 - # via pydantic -pytest==8.3.3 - # via -r dev_requirements/requirements-tests.in -typing-extensions==4.10.0 - # via - # pydantic - # pydantic-core diff --git a/dev_requirements/requirements-type_check.in b/dev_requirements/requirements-type_check.in deleted file mode 100644 index 4446a91..0000000 --- a/dev_requirements/requirements-type_check.in +++ /dev/null @@ -1,2 +0,0 @@ -# specific requirements for the tox type_check environment -mypy diff --git a/dev_requirements/requirements-type_check.txt b/dev_requirements/requirements-type_check.txt deleted file mode 100644 index f7be03e..0000000 --- a/dev_requirements/requirements-type_check.txt +++ /dev/null @@ -1,13 +0,0 @@ -# SHA1:7983aaa01d64547827c20395d77e248c41b2572f -# -# This file is autogenerated by pip-compile-multi -# To update, run: -# -# pip-compile-multi -# -mypy==1.11.2 - # via -r dev_requirements/requirements-type_check.in -mypy-extensions==1.0.0 - # via mypy -typing-extensions==4.10.0 - # via mypy diff --git a/pyproject.toml b/pyproject.toml index 5743003..79a015f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,32 @@ classifiers = [ dependencies = [] # add all the dependencies from requirements.in here, too dynamic = ["readme", "version"] +[project.optional-dependencies] +coverage = [ + "coverage==7.6.1" +] +formatting = [ + "black==24.8.0", + "isort==5.13.2" +] +linting = [ + "pylint==3.3.0" +] +spellcheck = [ + "codespell==2.3.0" +] +test_packaging = [ + "build==1.2.2", + "twine==5.1.1" +] +tests = [ + "pydantic==2.9.2", + "pytest==8.3.3" +] +type_check = [ + "mypy==1.11.2" +] + [project.urls] Changelog = "https://github.com/Hochfrequenz/python-generics/releases" Homepage = "https://github.com/Hochfrequenz/python-generics" diff --git a/tox.ini b/tox.ini index f9bb4bc..062b88c 100644 --- a/tox.ini +++ b/tox.ini @@ -14,7 +14,7 @@ commands = python -m pip install --upgrade pip # the tests environment is called by the Github action that runs the unit tests deps = -r requirements.txt - -r dev_requirements/requirements-tests.txt + .[tests] setenv = PYTHONPATH = {toxinidir}/src commands = python -m pytest --basetemp={envtmpdir} {posargs} @@ -23,7 +23,7 @@ commands = # the tests environment is called by the Github action that runs the unit tests deps = -r requirements.txt - -r dev_requirements/requirements-tests.txt + .[tests] setenv = PYTHONPATH = {toxinidir}/src commands = python -m pytest --basetemp={envtmpdir} --ignore=unittests/test_py_312.py {posargs} @@ -32,7 +32,7 @@ commands = # the linting environment is called by the Github Action that runs the linter deps = {[testenv:tests-py312]deps} - -r dev_requirements/requirements-linting.txt + .[linting] # add your fixtures like e.g. pytest_datafiles here setenv = PYTHONPATH = {toxinidir}/src commands = @@ -45,7 +45,7 @@ commands = setenv = PYTHONPATH = {toxinidir}/src deps = {[testenv:tests-py312]deps} - -r dev_requirements/requirements-type_check.txt + .[type_check] commands = mypy --show-error-codes src/generics mypy --show-error-codes --enable-incomplete-feature=NewGenericSyntax unittests @@ -56,7 +56,7 @@ commands = changedir = unittests deps = {[testenv:tests-py312]deps} - -r dev_requirements/requirements-coverage.txt + .[coverage] setenv = PYTHONPATH = {toxinidir}/src commands = coverage run -m pytest --basetemp={envtmpdir} {posargs} @@ -71,7 +71,7 @@ deps = {[testenv:linting]deps} {[testenv:type_check]deps} {[testenv:coverage]deps} - -r dev_requirements/requirements-formatting.txt + .[formatting] pip-tools pre-commit commands = @@ -83,7 +83,7 @@ commands = [testenv:test_packaging] skip_install = true deps = - -r dev_requirements/requirements-packaging.txt + .[test_packaging] commands = python -m build twine check dist/*