From 8d82d6d1587f354b3f930c39948d358be645d22e Mon Sep 17 00:00:00 2001 From: Freddy <100769900+FreddyFox892@users.noreply.github.com> Date: Fri, 27 Sep 2024 12:11:51 +0200 Subject: [PATCH] Move optional dependencies from `dev_requirements` to `pyproject.toml` (#239) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Move optional dependencies from `dev_requirements` to `pyproject.toml` * black & isort * .. * update pylint disable * ää * öö * del * . * p * pylint dis * rm version file after installation for linting env * Update tox.ini * revert experiments * publisch workflow * rmv experiments * ignore version py * add formatcheck * test --------- Co-authored-by: konstantin --- .github/workflows/formatting.yml | 2 +- .github/workflows/python-publish.yml | 10 ++- 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 | 79 -------------------- dev_requirements/requirements-tests.in | 4 - dev_requirements/requirements-tests.txt | 24 ------ dev_requirements/requirements-type_check.in | 2 - dev_requirements/requirements-type_check.txt | 13 ---- domain-specific-terms.txt | 1 + pyproject.toml | 30 ++++++++ requirements.txt | 2 + tox.ini | 32 ++++++-- 18 files changed, 66 insertions(+), 194 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 create mode 100644 domain-specific-terms.txt diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml index d02b098..4623a20 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..b6be6bf 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 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 ed1a620..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.1 - # 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 3c3b194..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.1 - # 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 9fef062..0000000 --- a/dev_requirements/requirements-packaging.in +++ /dev/null @@ -1,3 +0,0 @@ -# requirements for the hatchling build system -build -twine diff --git a/dev_requirements/requirements-packaging.txt b/dev_requirements/requirements-packaging.txt deleted file mode 100644 index e12bfe9..0000000 --- a/dev_requirements/requirements-packaging.txt +++ /dev/null @@ -1,79 +0,0 @@ -# SHA1:93e4fbf2b6cce1574fe3d5315360512fa9927699 -# -# This file is autogenerated by pip-compile-multi -# To update, run: -# -# pip-compile-multi -# -build==1.2.2 - # via -r dev_requirements/requirements-packaging.in -certifi==2024.7.4 - # via requests -cffi==1.16.0 - # via cryptography -charset-normalizer==3.3.2 - # via requests -cryptography==43.0.1 - # via secretstorage -docutils==0.21.2 - # via readme-renderer -idna==3.7 - # via requests -importlib-metadata==7.1.0 - # via twine -jaraco-classes==3.4.0 - # via keyring -jaraco-context==5.3.0 - # via keyring -jaraco-functools==4.0.1 - # via keyring -jeepney==0.8.0 - # via - # keyring - # secretstorage -keyring==25.2.0 - # via twine -markdown-it-py==3.0.0 - # via rich -mdurl==0.1.2 - # via markdown-it-py -more-itertools==10.5.0 - # via - # jaraco-classes - # jaraco-functools -nh3==0.2.17 - # via readme-renderer -packaging==24.0 - # via build -pkginfo==1.10.0 - # via twine -pycparser==2.22 - # via cffi -pygments==2.18.0 - # via - # readme-renderer - # rich -pyproject-hooks==1.1.0 - # via build -readme-renderer==43.0 - # via twine -requests==2.32.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.2 - # via - # requests - # twine -zipp==3.19.1 - # via importlib-metadata diff --git a/dev_requirements/requirements-tests.in b/dev_requirements/requirements-tests.in deleted file mode 100644 index 303fe73..0000000 --- a/dev_requirements/requirements-tests.in +++ /dev/null @@ -1,4 +0,0 @@ -# specific requirements for the tox tests env -pytest -pytest-datafiles -pytest-subtests diff --git a/dev_requirements/requirements-tests.txt b/dev_requirements/requirements-tests.txt deleted file mode 100644 index 55196f5..0000000 --- a/dev_requirements/requirements-tests.txt +++ /dev/null @@ -1,24 +0,0 @@ -# SHA1:237de32e0e58475d734882e72523b53d0f1187a3 -# -# This file is autogenerated by pip-compile-multi -# To update, run: -# -# pip-compile-multi -# -attrs==24.2.0 - # via pytest-subtests -iniconfig==2.0.0 - # via pytest -packaging==24.0 - # via pytest -pluggy==1.5.0 - # via pytest -pytest==8.3.3 - # via - # -r dev_requirements/requirements-tests.in - # pytest-datafiles - # pytest-subtests -pytest-datafiles==3.0.0 - # via -r dev_requirements/requirements-tests.in -pytest-subtests==0.13.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 b11b5b3..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.11.0 - # via mypy diff --git a/domain-specific-terms.txt b/domain-specific-terms.txt new file mode 100644 index 0000000..ee2a9a2 --- /dev/null +++ b/domain-specific-terms.txt @@ -0,0 +1 @@ +# contains 1 lower case word per line which are ignored in the spell_check diff --git a/pyproject.toml b/pyproject.toml index e4ba3d9..130ee62 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,6 +26,33 @@ dependencies = [ ] 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 = [ + "pytest==8.3.3", + "pytest-datafiles==3.0.0", + "pytest-subtests==0.13.1" +] +type_check = [ + "mypy==1.11.2" +] + [project.urls] Changelog = "https://github.com/Hochfrequenz/ebdamame/releases" Homepage = "https://github.com/Hochfrequenz/ebdamame" @@ -59,6 +86,9 @@ source = "vcs" [tool.hatch.build.hooks.vcs] version-file = "src/ebdamame/version.py" +template = ''' +version = "{version}" +''' [tool.hatch.build.targets.sdist] exclude = ["/unittests"] diff --git a/requirements.txt b/requirements.txt index f2d126f..74652c9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,6 +17,8 @@ charset-normalizer==3.3.2 # via requests click==8.1.7 # via -r requirements.in +colorama==0.4.6 + # via click idna==3.7 # via requests lxml==5.2.1 diff --git a/tox.ini b/tox.ini index f0b146b..ce21061 100644 --- a/tox.ini +++ b/tox.ini @@ -4,6 +4,7 @@ envlist = linting coverage type_check + formatcheck skip_missing_interpreters = True skipsdist = True @@ -14,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} @@ -22,11 +23,11 @@ commands = python -m pytest --basetemp={envtmpdir} {posargs} # the linting environment is called by the Github Action that runs the linter deps = -r requirements.txt - -r dev_requirements/requirements-linting.txt + .[linting] # add your fixtures like e.g. pytest_datafiles here setenv = PYTHONPATH = {toxinidir}/src commands = - pylint ebdamame + pylint ebdamame --ignore=version.py pylint main.py # add single files (ending with .py) or packages here @@ -35,18 +36,35 @@ commands = setenv = PYTHONPATH = {toxinidir}/src deps = -r requirements.txt - -r dev_requirements/requirements-type_check.txt + .[type_check] commands = mypy --show-error-codes --strict src/ebdamame mypy --show-error-codes unittests mypy --show-error-codes main.py # add single files (ending with .py) or packages here +[testenv:formatcheck] +deps = + .[formatting] +commands = + black . --check + isort . --check + +[testenv:spell_check] +# the spellcheck environment checks the code for typos +setenv = PYTHONPATH = {toxinidir}/src +deps = + -r requirements.txt + .[spellcheck] +commands = + codespell --ignore-words=domain-specific-terms.txt src + codespell --ignore-words=domain-specific-terms.txt README.md + [testenv:coverage] # 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} @@ -56,7 +74,7 @@ commands = [testenv:test_packaging] skip_install = true deps = - -r dev_requirements/requirements-packaging.txt + .[test_packaging] commands = python -m build twine check dist/* @@ -68,7 +86,7 @@ deps = {[testenv:linting]deps} {[testenv:type_check]deps} {[testenv:coverage]deps} - -r dev_requirements/requirements-formatting.txt + .[formatting] pip-tools pre-commit commands =