From 1f83cfecd121d88b2daadf6546e280923b175d04 Mon Sep 17 00:00:00 2001 From: David Salvisberg Date: Wed, 27 May 2026 13:37:12 +0200 Subject: [PATCH] Switch to pyproject.toml based project setup --- .github/workflows/main.yml | 10 +-- .pre-commit-config.yaml | 3 +- README.rst | 2 +- develop_requirements.txt | 5 +- doc/developing.rst | 4 +- pyproject.toml | 121 +++++++++++++++++++++++++++++++++++++ reg/arginfo.py | 2 +- setup.cfg | 20 ------ setup.py | 41 ------------- tox.ini | 48 --------------- 10 files changed, 131 insertions(+), 125 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.cfg delete mode 100644 setup.py delete mode 100644 tox.ini diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c871310..0a43517 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,7 @@ jobs: strategy: matrix: - python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "pypy3.10"] + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "pypy3.11"] # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -29,13 +29,7 @@ jobs: with: python-version: "${{ matrix.python-version }}" - name: "Install dependencies" - run: | - set -xe - python -VV - python -m site - python -m pip install --upgrade pip setuptools wheel - # FIXME: Make tox.ini compatible with newer versions of tox - python -m pip install --upgrade virtualenv 'tox<4' tox-gh-actions + run: python -m pip install --upgrade pip tox tox-gh - name: "Run tox targets for ${{ matrix.python-version }}" run: "python -m tox" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e18d7ba..d17a26e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,8 +7,9 @@ repos: rev: "7.3.0" hooks: - id: flake8 + additional_dependencies: [flake8-pyproject] - repo: https://github.com/asottile/pyupgrade rev: v3.21.2 hooks: - id: pyupgrade - args: [--py36-plus] + args: [--py310-plus] diff --git a/README.rst b/README.rst index b5deced..831d02c 100644 --- a/README.rst +++ b/README.rst @@ -13,7 +13,7 @@ Reg: Clever Dispatch -==================== +******************** Reg is a Python library that provides generic function support to Python. It help you build powerful registration and configuration APIs diff --git a/develop_requirements.txt b/develop_requirements.txt index 980b2f2..780e977 100644 --- a/develop_requirements.txt +++ b/develop_requirements.txt @@ -1,8 +1,7 @@ # development --e '.[test,coverage,pep8,docs]' +-e '.[test,coverage,lint,docs]' pre-commit -# FIXME: Make tox.ini compatible with newer versions of tox -tox >= 2.4.1, < 4 +tox >= 4 radon # releaser diff --git a/doc/developing.rst b/doc/developing.rst index 59abc32..3a79b6f 100644 --- a/doc/developing.rst +++ b/doc/developing.rst @@ -165,8 +165,8 @@ You can run all tox tests with:: You can also specify a test environment to run e.g.:: - $ tox -e py37 - $ tox -e pep8 + $ tox -e py311 + $ tox -e lint $ tox -e docs To run a simple performance test you can use:: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f105828 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,121 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "reg" +version = "0.13.dev0" +dynamic = ["readme"] +description = "Clever dispatch" +license = "BSD-3-Clause" +license-files = ["LICENSE.txt"] +authors = [{name = "Martijn Faassen", email = "faassen@startifact.com"}] +maintainers = [{name = "Henri Hulski", email = "henri@sancode.it"}] +classifiers = [ + "Intended Audience :: Developers", + "Topic :: Software Development :: Libraries :: Python Modules", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: Implementation :: PyPy", + "Development Status :: 5 - Production/Stable", +] +requires-python = ">= 3.10" +dependencies = ["repoze.lru"] + +[project.urls] +Documentation = "https://reg.readthedocs.io" +Repository = "https://github.com/morepath/reg" +Issues = "https://github.com/morepath/reg/issues" +Changelog = "https://github.com/morepath/reg/blob/master/CHANGES.txt" + +[project.optional-dependencies] +test = ["pytest >= 8", "pytest-env", "sphinx"] +docs = ["sphinx"] +coverage = ["pytest-cov"] +lint = ["black", "flake8", "flake8-pyproject"] + +[tool.setuptools.packages] +find = {} + +[tool.setuptools.dynamic] +readme = {file = ["README.rst", "CHANGES.txt"]} + +[tool.pytest.ini_options] +minversion = "8.0" +testpaths = ["reg"] +addopts = ["-vv"] +env = ["RUN_ENV=test"] + +[tool.coverage.run] +omit = ["reg/tests/*"] +source = ["reg"] + +[tool.coverage.report] +show_missing = true + +[tool.flake8] +show-source = true +ignore = ["E203", "E731", "W503"] +max-line-length = 88 + +[tool.tox] +requires = ["tox>=4"] +env_list = [ + "py310", + "py311", + "py312", + "py313", + "py314", + "pypy3", + "coverage", + "pre-commit", + "docs", + "perf", +] +skip_missing_interpreters = true + +[tool.tox.gh.python] +"3.10" = ["py310", "perf"] +"3.11" = ["py311"] +"3.12" = ["py312"] +"3.13" = ["py313"] +"3.14" = ["py314", "pre-commit", "coverage"] +"pypy-3.11" = ["pypy3"] + +[tool.tox.env_run_base] +package = "editable" +extras = ["test"] +commands = [["pytest", "{posargs:reg}"]] + +[tool.tox.env.coverage] +base_python = ["python3"] +extras = ["test", "coverage"] +commands = [ + ["pytest", "--cov", "--cov-fail-under=100", "{posargs:reg}"], +] + +[tool.tox.env.pre-commit] +base_python = ["python3"] +package = "skip" +deps = ["pre-commit"] +commands = [ + ["pre-commit", "run", "--all-files"], +] + +[tool.tox.env.docs] +base_python = ["python3"] +extras = ["docs"] +commands = [ + ["sphinx-build", "-b", "doctest", "doc", "{env_tmp_dir}"], +] + +[tool.tox.env.perf] +base_python = ["python3"] +extras = [] +commands = [ + ["python", "{toxinidir}/tox_perf.py"], +] diff --git a/reg/arginfo.py b/reg/arginfo.py index aa008df..42c3ee7 100644 --- a/reg/arginfo.py +++ b/reg/arginfo.py @@ -8,7 +8,7 @@ def get_signature(callable): # pragma: no cover return inspect.signature(callable) else: - from annotationlib import Format + from annotationlib import Format # pragma: no cover def get_signature(callable): # pragma: no cover """A compatibility wrapper for `inspect.signature`.""" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 7d3fc43..0000000 --- a/setup.cfg +++ /dev/null @@ -1,20 +0,0 @@ -[flake8] -show-source = True -ignore = E203, E731, W503 -max-line-length = 88 - -[tool:pytest] -testpaths = reg - -[coverage:run] -omit = reg/tests/* -source = reg - -[coverage:report] -show_missing = True - -[zest.releaser] -create-wheel = yes - -[bdist_wheel] -universal = 1 diff --git a/setup.py b/setup.py deleted file mode 100644 index 5c21023..0000000 --- a/setup.py +++ /dev/null @@ -1,41 +0,0 @@ -from setuptools import setup, find_packages - -long_description = "\n".join( - ( - open("README.rst", encoding="utf-8").read(), - open("CHANGES.txt", encoding="utf-8").read(), - ) -) - -setup( - name="reg", - version="0.13.dev0", - description="Clever dispatch", - long_description=long_description, - author="Martijn Faassen", - author_email="faassen@startifact.com", - license="BSD", - url="http://reg.readthedocs.io", - packages=find_packages(), - include_package_data=True, - zip_safe=False, - classifiers=[ - "Intended Audience :: Developers", - "License :: OSI Approved :: BSD License", - "Topic :: Software Development :: Libraries :: Python Modules", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", - "Programming Language :: Python :: 3.14", - "Programming Language :: Python :: Implementation :: PyPy", - "Development Status :: 5 - Production/Stable", - ], - install_requires=["setuptools", "repoze.lru"], - extras_require=dict( - test=["pytest >= 2.9.0", "sphinx", "pytest-remove-stale-bytecode"], - pep8=["flake8", "black"], - coverage=["pytest-cov"], - docs=["sphinx"], - ), -) diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 3fbe487..0000000 --- a/tox.ini +++ /dev/null @@ -1,48 +0,0 @@ -[tox] -envlist = py310, py311, py312, py313, py314, pypy3, coverage, pre-commit, docs, perf -skipsdist = True -skip_missing_interpreters = True - -[testenv] -usedevelop = True -extras = test -commands = pytest {posargs} - -[testenv:coverage] -basepython = python -extras = test - coverage - -commands = pytest --cov --cov-fail-under=100 {posargs} - -[testenv:pre-commit] -deps = pre-commit -commands = pre-commit run --all-files - -[testenv:docs] -basepython = python3 -extras = docs - -commands = sphinx-build -b doctest doc {envtmpdir} - -[testenv:perf] -basepython = python3 -extras = - -commands = python {toxinidir}/tox_perf.py - -[gh-actions] -python = - 3.10: py310, perf - 3.11: py311 - 3.12: py312 - 3.13: py313 - 3.14: py314, pre-commit, coverage - pypy-3.10: pypy3 - -[flake8] -max-line-length = 88 -ignore = - E231 # clashes with black - W503 - E731 # todo