From 7115d641a17fce8432c6b1a9902d8be2a9950756 Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Fri, 22 Nov 2024 21:43:59 +0100 Subject: [PATCH] modernize everything --- .gitmodules | 2 +- CHANGELOG.rst | 6 +- MANIFEST.in | 9 +- pyproject.toml | 101 ++++++++++++++++++++ setup.cfg | 27 ------ setup.py | 50 ---------- {test => tests}/__init__.py | 0 {test => tests}/http2-frame-test-case | 0 {test => tests}/test_external_collection.py | 0 {test => tests}/test_flags.py | 0 {test => tests}/test_frames.py | 0 tox.ini | 24 ++--- 12 files changed, 119 insertions(+), 100 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.cfg delete mode 100644 setup.py rename {test => tests}/__init__.py (100%) rename {test => tests}/http2-frame-test-case (100%) rename {test => tests}/test_external_collection.py (100%) rename {test => tests}/test_flags.py (100%) rename {test => tests}/test_frames.py (100%) diff --git a/.gitmodules b/.gitmodules index c39273c..d7710d4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "test/http2-frame-test-case"] - path = test/http2-frame-test-case + path = tests/http2-frame-test-case url = https://github.com/http2jp/http2-frame-test-case.git diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2aa8556..100af6c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -16,10 +16,8 @@ dev - Support for Python 3.11 has been added. - Support for Python 3.12 has been added. - Support for Python 3.13 has been added. - -**Bugfixes** - -- +- Improved type hints. +- Updated packaging and testing infrastructure. 6.0.1 (2021-04-17) ------------------ diff --git a/MANIFEST.in b/MANIFEST.in index 85d1ba5..3af4619 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,10 @@ graft src/hyperframe graft docs -graft test +graft tests + prune docs/build -prune test/http2-frame-test-case -include README.rst LICENSE CHANGELOG.rst CONTRIBUTORS.rst tox.ini .gitmodules +prune tests/http2-frame-test-case + +include README.rst LICENSE CHANGELOG.rst CONTRIBUTORS.rst pyproject.toml tox.ini .gitmodules + global-exclude *.pyc *.pyo *.swo *.swp *.map *.yml *.DS_Store diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..a281102 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,101 @@ +# https://packaging.python.org/en/latest/guides/writing-pyproject-toml/ +# https://packaging.python.org/en/latest/specifications/pyproject-toml/ + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "hyperframe" +description = "HTTP/2 framing layer for Python" +readme = { file = "README.rst", content-type = "text/x-rst" } +license = { file = "LICENSE" } + +authors = [ + { name = "Cory Benfield", email = "cory@lukasa.co.uk" } +] +maintainers = [ + { name = "Thomas Kriechbaumer", email = "thomas@kriechbaumer.name" }, +] + +requires-python = ">=3.9" +dependencies = [] +dynamic = ["version"] + +# For a list of valid classifiers, see https://pypi.org/classifiers/ +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", +] + +[project.urls] +"Homepage" = "https://github.com/python-hyper/hyperframe/" +"Bug Reports" = "https://github.com/python-hyper/hyperframe/issues" +"Source" = "https://github.com/python-hyper/hyperframe/" +"Documentation" = "https://python-hyper.org/" + +[dependency-groups] +testing = [ + "pytest>=8.3.3,<9", + "pytest-cov>=6.0.0,<7", + "pytest-xdist>=3.6.1,<4", +] + +linting = [ + "ruff>=0.8.0,<1", + "mypy>=1.13.0,<2", +] + +packaging = [ + "check-manifest==0.50", + "readme-renderer==44.0", + "build>=1.2.2,<2", + "twine>=5.1.1,<6", + "wheel>=0.45.0,<1", +] + +docs = [ + "sphinx>=7.4.7,<9", +] + +[tool.setuptools.packages.find] +where = [ "src" ] + +[tool.setuptools.package-data] +hyperframe = [ "py.typed" ] + +[tool.setuptools.dynamic] +version = { attr = "hyperframe.__version__" } + +[tool.check-manifest] +ignore = [ + "Makefile", + "tests/http2-frame-test-case", +] + +[tool.ruff] +line-length = 140 +target-version = "py39" + +[tool.coverage.run] +branch = true +source = [ "hyperframe" ] + +[tool.coverage.report] +fail_under = 100 +show_missing = true +exclude_lines = [ + "pragma: no cover", + "raise NotImplementedError()", +] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 5d716ed..0000000 --- a/setup.cfg +++ /dev/null @@ -1,27 +0,0 @@ -[tool:pytest] -testpaths = test - -[coverage:run] -branch = True -source = hyperframe - -[coverage:report] -fail_under = 100 -show_missing = True -exclude_lines = - pragma: no cover - raise NotImplementedError() - -[coverage:paths] -source = - src - .tox/*/site-packages - -[flake8] -max-line-length = 120 -max-complexity = 10 - -[check-manifest] -ignore = - Makefile - test/http2-frame-test-case diff --git a/setup.py b/setup.py deleted file mode 100644 index 01ee2f0..0000000 --- a/setup.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python3 - -import os -import re - -from setuptools import setup, find_packages - -PROJECT_ROOT = os.path.dirname(__file__) - -with open(os.path.join(PROJECT_ROOT, 'README.rst')) as file_: - long_description = file_.read() - -version_regex = r'__version__ = ["\']([^"\']*)["\']' -with open(os.path.join(PROJECT_ROOT, 'src/hyperframe/__init__.py')) as file_: - text = file_.read() - match = re.search(version_regex, text) - if match: - version = match.group(1) - else: - raise RuntimeError("No version number found!") - -setup( - name='hyperframe', - version=version, - description='HTTP/2 framing layer for Python', - long_description=long_description, - long_description_content_type='text/x-rst', - author='Cory Benfield', - author_email='cory@lukasa.co.uk', - url='https://github.com/python-hyper/hyperframe/', - packages=find_packages(where="src"), - package_data={'hyperframe': ['py.typed']}, - package_dir={'': 'src'}, - python_requires='>=3.9.0', - license='MIT License', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Programming Language :: Python :: 3.13', - 'Programming Language :: Python :: Implementation :: CPython', - 'Programming Language :: Python :: Implementation :: PyPy', - ], -) diff --git a/test/__init__.py b/tests/__init__.py similarity index 100% rename from test/__init__.py rename to tests/__init__.py diff --git a/test/http2-frame-test-case b/tests/http2-frame-test-case similarity index 100% rename from test/http2-frame-test-case rename to tests/http2-frame-test-case diff --git a/test/test_external_collection.py b/tests/test_external_collection.py similarity index 100% rename from test/test_external_collection.py rename to tests/test_external_collection.py diff --git a/test/test_flags.py b/tests/test_flags.py similarity index 100% rename from test/test_flags.py rename to tests/test_flags.py diff --git a/test/test_frames.py b/tests/test_frames.py similarity index 100% rename from test/test_frames.py rename to tests/test_frames.py diff --git a/tox.ini b/tox.ini index 50e5b2b..dfca357 100644 --- a/tox.ini +++ b/tox.ini @@ -13,10 +13,7 @@ python = [testenv] passenv = GITHUB_* -deps = - pytest>=6.0.1,<7 - pytest-cov>=2.10.1,<3 - pytest-xdist>=2.2.1,<3 +dependency_groups = testing commands = pytest --cov-report=xml --cov-report=term --cov=hyperframe {posargs} @@ -25,16 +22,16 @@ commands = commands = pytest {posargs} [testenv:lint] -deps = - flake8>=7.1.1,<8 - mypy>=1.13.0,<2 +dependency_groups = linting +allowlist_externals = + ruff + mypy commands = - flake8 src/ test/ + ruff check src/ tests/ mypy --strict src/ [testenv:docs] -deps = - sphinx>=7.4.7,<9 +dependency_groups = docs allowlist_externals = make changedir = {toxinidir}/docs commands = @@ -43,15 +40,12 @@ commands = [testenv:packaging] basepython = python3.9 -deps = - check-manifest==0.50 - readme-renderer==44.0 - twine>=5.1.1,<6 +dependency_groups = packaging allowlist_externals = rm commands = rm -rf dist/ check-manifest - python setup.py sdist bdist_wheel + python -m build --outdir dist/ twine check dist/* [testenv:publish]