From 0d3bcd3b76237d7d25165cdf2e1cfe2fc60e00a4 Mon Sep 17 00:00:00 2001 From: Freddy <100769900+FreddyFox892@users.noreply.github.com> Date: Wed, 25 Sep 2024 14:57:11 +0200 Subject: [PATCH] Move optional dependencies from `dev_requirements` to `pyproject.toml` (#157) * Move optional dependencies from `dev_requirements` to `pyproject.toml` * add maus --- .github/workflows/formatting.yml | 2 +- .github/workflows/python-publish.yml | 10 ++- dev_requirements/requirements-coverage.in | 3 - dev_requirements/requirements-coverage.txt | 13 ---- 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 | 72 ------------------- dev_requirements/requirements-spell_check.in | 1 - dev_requirements/requirements-spell_check.txt | 9 --- dev_requirements/requirements-tests.in | 5 -- dev_requirements/requirements-tests.txt | 38 ---------- dev_requirements/requirements-type_check.in | 2 - dev_requirements/requirements-type_check.txt | 13 ---- pyproject.toml | 38 +++++++++- tox.ini | 23 +++--- 18 files changed, 53 insertions(+), 226 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-spell_check.in delete mode 100644 dev_requirements/requirements-spell_check.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 f9074e6..c977d7b 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/formatting.yml @@ -21,7 +21,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 596dc52..7b51c76 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 @@ -45,14 +49,14 @@ jobs: needs: tests steps: - uses: actions/checkout@v4 - - name: Set up Python + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - 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 987838e..0000000 --- a/dev_requirements/requirements-coverage.in +++ /dev/null @@ -1,3 +0,0 @@ -# specific requirements for the tox coverage env -coverage -pytest_loguru diff --git a/dev_requirements/requirements-coverage.txt b/dev_requirements/requirements-coverage.txt deleted file mode 100644 index 2b7e41d..0000000 --- a/dev_requirements/requirements-coverage.txt +++ /dev/null @@ -1,13 +0,0 @@ -# SHA1:5c99babe62754a9fe23771e877f18d99a3faa208 -# -# 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 -loguru==0.7.2 - # via pytest-loguru -pytest-loguru==0.4.0 - # 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 7f46e21..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.1 - # 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 a1ce9fb..0000000 --- a/dev_requirements/requirements-packaging.txt +++ /dev/null @@ -1,72 +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 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.1 - # 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-spell_check.in b/dev_requirements/requirements-spell_check.in deleted file mode 100644 index e3da9e4..0000000 --- a/dev_requirements/requirements-spell_check.in +++ /dev/null @@ -1 +0,0 @@ -codespell diff --git a/dev_requirements/requirements-spell_check.txt b/dev_requirements/requirements-spell_check.txt deleted file mode 100644 index 5f6029e..0000000 --- a/dev_requirements/requirements-spell_check.txt +++ /dev/null @@ -1,9 +0,0 @@ -# SHA1:a7062511e9640ed2a5c2dea1da5c8b5f59c0f0d7 -# -# This file is autogenerated by pip-compile-multi -# To update, run: -# -# pip-compile-multi -# -codespell==2.3.0 - # via -r dev_requirements/requirements-spell_check.in diff --git a/dev_requirements/requirements-tests.in b/dev_requirements/requirements-tests.in deleted file mode 100644 index a5f977d..0000000 --- a/dev_requirements/requirements-tests.in +++ /dev/null @@ -1,5 +0,0 @@ -# specific requirements for the tox tests env -pytest -pytest_loguru # makes loguru logs accessible to pytest -maus[tree] -syrupy diff --git a/dev_requirements/requirements-tests.txt b/dev_requirements/requirements-tests.txt deleted file mode 100644 index 689d9b5..0000000 --- a/dev_requirements/requirements-tests.txt +++ /dev/null @@ -1,38 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.12 -# by the following command: -# -# pip-compile '.\dev_requirements\requirements-tests.in' -# -attrs==23.2.0 - # via maus -efoli==1.1.0 - # via maus -iniconfig==2.0.0 - # via pytest -lark==1.1.9 - # via maus -loguru==0.7.2 - # via pytest-loguru -marshmallow==3.21.3 - # via maus -maus[tree]==0.6.1 - # via -r dev_requirements/requirements-tests.in -more-itertools==10.3.0 - # via maus -packaging==24.1 - # via - # marshmallow - # pytest -pluggy==1.5.0 - # via pytest -pytest==8.3.3 - # via - # -r dev_requirements/requirements-tests.in - # syrupy -pytest-loguru==0.4.0 - # via -r dev_requirements/requirements-tests.in -pytz==2024.2 - # via efoli -syrupy==4.7.1 - # via -r dev_requirements/requirements-tests.in 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 ee53d57..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.12.2 - # via mypy diff --git a/pyproject.toml b/pyproject.toml index 5077e98..84bcf54 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,11 +17,45 @@ classifiers = [ "Programming Language :: Python :: 3.12", ] -dependencies = ["click", "loguru", "jinja2", "pydantic", "python-docx", "efoli>=0.0.3"] # add all the dependencies here - +dependencies = [ + "click", + "loguru", + "jinja2", + "pydantic", + "python-docx", + "efoli>=0.0.3" +] # add all the dependencies here 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 = [ + "maus[tree]==0.6.1", + "pytest==8.3.3", + "pytest-loguru==0.4.0", + "syrupy==4.7.1" +] +type_check = [ + "mypy==1.11.2" +] + [project.urls] Changelog = "https://github.com/Hochfrequenz/migmose/releases" Homepage = "https://github.com/Hochfrequenz/migmose" diff --git a/tox.ini b/tox.ini index c59413e..9b907ea 100644 --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,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 = python -m pytest --basetemp={envtmpdir} {posargs} # 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] syrupy setenv = PYTHONPATH = {toxinidir}/src commands = python -m pytest --basetemp={envtmpdir} {posargs} --snapshot-update @@ -32,10 +32,11 @@ commands = python -m pytest --basetemp={envtmpdir} {posargs} --snapshot-update # the linting environment is called by the Github Action that runs the linter deps = {[testenv:tests]deps} - -r dev_requirements/requirements-linting.txt + .[linting] # add your fixtures like e.g. pytest_datafiles here setenv = PYTHONPATH = {toxinidir}/src commands = + pylint src --ignore=_migmose_version.py pylint migmose pylint unittests --rcfile=unittests/.pylintrc # add single files (ending with .py) or packages here @@ -45,7 +46,7 @@ commands = setenv = PYTHONPATH = {toxinidir}/src deps = {[testenv:tests]deps} - -r dev_requirements/requirements-type_check.txt + .[type_check] commands = mypy --show-error-codes src/migmose --strict mypy --show-error-codes unittests @@ -56,7 +57,7 @@ commands = setenv = PYTHONPATH = {toxinidir}/src deps = -r requirements.txt - -r dev_requirements/requirements-spell_check.txt + .[spellcheck] commands = codespell --ignore-words=domain-specific-terms.txt src codespell --ignore-words=domain-specific-terms.txt README.md @@ -66,19 +67,13 @@ commands = # the coverage environment is called by the Github Action that runs the coverage measurement deps = {[testenv:tests]deps} - -r dev_requirements/requirements-coverage.txt + .[coverage] setenv = PYTHONPATH = {toxinidir}/src commands = coverage run -m pytest --basetemp={envtmpdir} {posargs} coverage html --omit .tox/*,unittests/*,src/migmose/__main__.py coverage report --fail-under 80 --omit .tox/*,unittests/*,src/migmose/__main__.py -[testenv:compile_requirements] -deps = - pip-compile-multi -commands = - pip-compile-multi -d dev_requirements --autoresolve - [testenv:dev] # the dev environment contains everything you need to start developing on your local machine. deps = @@ -87,7 +82,7 @@ deps = {[testenv:type_check]deps} {[testenv:coverage]deps} {[testenv:spell_check]deps} - -r dev_requirements/requirements-formatting.txt + .[formatting] pip-tools pre-commit commands = @@ -98,7 +93,7 @@ commands = [testenv:test_packaging] skip_install = true deps = - -r dev_requirements/requirements-packaging.txt + .[test_packaging] commands = python -m build twine check dist/*