diff --git a/CHANGES/9951.packaging.rst b/CHANGES/9951.packaging.rst new file mode 100644 index 00000000000..5c7154879ec --- /dev/null +++ b/CHANGES/9951.packaging.rst @@ -0,0 +1 @@ +Moved static metadata from ``setup.cfg`` to ``pyproject.toml`` -- by :user:`cdce8p`. diff --git a/Makefile b/Makefile index 0163b771b8a..bb6b1383237 100644 --- a/Makefile +++ b/Makefile @@ -191,5 +191,5 @@ install-dev: .develop .PHONY: sync-direct-runtime-deps sync-direct-runtime-deps: - @echo Updating 'requirements/runtime-deps.in' from 'setup.cfg'... >&2 + @echo Updating 'requirements/runtime-deps.in' from 'pyproject.toml'... >&2 @python requirements/sync-direct-runtime-deps.py diff --git a/pyproject.toml b/pyproject.toml index e21ba283b11..eb227057565 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,74 @@ [build-system] -requires = [ - "setuptools >= 46.4.0", -] +requires = ["setuptools >= 70.0.0"] build-backend = "setuptools.build_meta" +[project] +name = "aiohttp" +license = {text = "Apache-2.0"} +description = "Async http client/server framework (asyncio)" +readme = "README.rst" +maintainers = [{name = "aiohttp team", email = "team@aiohttp.org"}] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Framework :: AsyncIO", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Operating System :: POSIX", + "Operating System :: MacOS :: MacOS X", + "Operating System :: Microsoft :: Windows", + "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", + "Topic :: Internet :: WWW/HTTP", +] +requires-python = ">=3.9" +dependencies = [ + "aiohappyeyeballs >= 2.3.0", + "aiosignal >= 1.1.2", + "async-timeout >= 4.0, < 6.0 ; python_version < '3.11'", + "frozenlist >= 1.1.1", + "multidict >=4.5, < 7.0", + "propcache >= 0.2.0", + "yarl >= 1.17.0, < 2.0", +] +dynamic = ["version"] + +[project.optional-dependencies] +speedups = [ + # required c-ares (aiodns' backend) will not build on windows + "aiodns >= 3.2.0; sys_platform=='linux' or sys_platform=='darwin'", + "Brotli; platform_python_implementation == 'CPython'", + "brotlicffi; platform_python_implementation != 'CPython'", +] + +[project.urls] +"Homepage" = "https://github.com/aio-libs/aiohttp" +"Chat: Matrix" = "https://matrix.to/#/#aio-libs:matrix.org" +"Chat: Matrix Space" = "https://matrix.to/#/#aio-libs-space:matrix.org" +"CI: GitHub Actions" = "https://github.com/aio-libs/aiohttp/actions?query=workflow%3ACI" +"Coverage: codecov" = "https://codecov.io/github/aio-libs/aiohttp" +"Docs: Changelog" = "https://docs.aiohttp.org/en/stable/changes.html" +"Docs: RTD" = "https://docs.aiohttp.org" +"GitHub: issues" = "https://github.com/aio-libs/aiohttp/issues" +"GitHub: repo" = "https://github.com/aio-libs/aiohttp" + +[tool.setuptools.dynamic] +version = {attr = "aiohttp.__version__"} + +[tool.setuptools.packages.find] +include = ["aiohttp*"] +exclude = ["examples"] + +[tool.setuptools.package-data] +"*" = ["*.so"] + +[tool.setuptools.exclude-package-data] +"*" = ["*.c", "*.h"] + [tool.towncrier] package = "aiohttp" filename = "CHANGES.rst" @@ -87,8 +152,3 @@ ignore-words-list = 'te,assertIn' # TODO(3.13): Remove aiohttp.helpers once https://github.com/python/cpython/pull/106771 # is available in all supported cpython versions exclude-modules = "(^aiohttp\\.helpers)" - -[tool.black] -# TODO: Remove when project metadata is moved here. -# Black can read the value from [project.requires-python]. -target-version = ["py39", "py310", "py311", "py312", "py313"] diff --git a/requirements/lint.in b/requirements/lint.in index 999f41b7a40..5112debbae4 100644 --- a/requirements/lint.in +++ b/requirements/lint.in @@ -8,6 +8,7 @@ pytest-mock pytest_codspeed python-on-whales slotscheck +tomli; python_version < '3.11' trustme uvloop; platform_system != "Windows" valkey diff --git a/requirements/lint.txt b/requirements/lint.txt index ae8a7f12007..cee11de184e 100644 --- a/requirements/lint.txt +++ b/requirements/lint.txt @@ -102,6 +102,7 @@ slotscheck==0.19.1 # via -r requirements/lint.in tomli==2.0.2 # via + # -r requirements/lint.in # mypy # pytest # slotscheck diff --git a/requirements/runtime-deps.in b/requirements/runtime-deps.in index 48ee7016d13..cb538b49490 100644 --- a/requirements/runtime-deps.in +++ b/requirements/runtime-deps.in @@ -1,9 +1,9 @@ -# Extracted from `setup.cfg` via `make sync-direct-runtime-deps` +# Extracted from `pyproject.toml` via `make sync-direct-runtime-deps` -aiodns >= 3.2.0; sys_platform=="linux" or sys_platform=="darwin" +aiodns >= 3.2.0; sys_platform=='linux' or sys_platform=='darwin' aiohappyeyeballs >= 2.3.0 aiosignal >= 1.1.2 -async-timeout >= 4.0, < 6.0 ; python_version < "3.11" +async-timeout >= 4.0, < 6.0 ; python_version < '3.11' Brotli; platform_python_implementation == 'CPython' brotlicffi; platform_python_implementation != 'CPython' frozenlist >= 1.1.1 diff --git a/requirements/sync-direct-runtime-deps.py b/requirements/sync-direct-runtime-deps.py index adc28bdd287..f29a861b01d 100755 --- a/requirements/sync-direct-runtime-deps.py +++ b/requirements/sync-direct-runtime-deps.py @@ -1,16 +1,22 @@ #!/usr/bin/env python -"""Sync direct runtime dependencies from setup.cfg to runtime-deps.in.""" +"""Sync direct runtime dependencies from pyproject.toml to runtime-deps.in.""" -from configparser import ConfigParser +import sys from pathlib import Path -cfg = ConfigParser() -cfg.read(Path("setup.cfg")) -reqs = cfg["options"]["install_requires"] + cfg.items("options.extras_require")[0][1] -reqs = sorted(reqs.split("\n"), key=str.casefold) -reqs.remove("") +if sys.version_info >= (3, 11): + import tomllib +else: + import tomli as tomllib + +data = tomllib.loads(Path("pyproject.toml").read_text()) +reqs = ( + data["project"]["dependencies"] + + data["project"]["optional-dependencies"]["speedups"] +) +reqs = sorted(reqs, key=str.casefold) with open(Path("requirements", "runtime-deps.in"), "w") as outfile: - header = "# Extracted from `setup.cfg` via `make sync-direct-runtime-deps`\n\n" + header = "# Extracted from `pyproject.toml` via `make sync-direct-runtime-deps`\n\n" outfile.write(header) outfile.write("\n".join(reqs) + "\n") diff --git a/setup.cfg b/setup.cfg index 66b779b8db9..478f13c0457 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,87 +1,3 @@ -[metadata] -name = aiohttp -version = attr: aiohttp.__version__ -url = https://github.com/aio-libs/aiohttp -project_urls = - Chat: Matrix = https://matrix.to/#/#aio-libs:matrix.org - Chat: Matrix Space = https://matrix.to/#/#aio-libs-space:matrix.org - CI: GitHub Actions = https://github.com/aio-libs/aiohttp/actions?query=workflow%%3ACI - Coverage: codecov = https://codecov.io/github/aio-libs/aiohttp - Docs: Changelog = https://docs.aiohttp.org/en/stable/changes.html - Docs: RTD = https://docs.aiohttp.org - GitHub: issues = https://github.com/aio-libs/aiohttp/issues - GitHub: repo = https://github.com/aio-libs/aiohttp -description = Async http client/server framework (asyncio) -long_description = file: README.rst -long_description_content_type = text/x-rst -maintainer = aiohttp team -maintainer_email = team@aiohttp.org -license = Apache-2.0 -license_files = LICENSE.txt -classifiers = - Development Status :: 5 - Production/Stable - - Framework :: AsyncIO - - Intended Audience :: Developers - - License :: OSI Approved :: Apache Software License - - Operating System :: POSIX - Operating System :: MacOS :: MacOS X - Operating System :: Microsoft :: Windows - - 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 - - Topic :: Internet :: WWW/HTTP - -[options] -python_requires = >=3.9 -packages = - aiohttp - aiohttp._websocket -# https://setuptools.readthedocs.io/en/latest/setuptools.html#setting-the-zip-safe-flag -zip_safe = False -include_package_data = True - -install_requires = - aiohappyeyeballs >= 2.3.0 - aiosignal >= 1.1.2 - async-timeout >= 4.0, < 6.0 ; python_version < "3.11" - frozenlist >= 1.1.1 - multidict >=4.5, < 7.0 - propcache >= 0.2.0 - yarl >= 1.17.0, < 2.0 - -[options.exclude_package_data] -* = - *.c - *.h - -[options.extras_require] -speedups = - # required c-ares (aiodns' backend) will not build on windows - aiodns >= 3.2.0; sys_platform=="linux" or sys_platform=="darwin" - Brotli; platform_python_implementation == 'CPython' - brotlicffi; platform_python_implementation != 'CPython' - -[options.packages.find] -exclude = - examples - -[options.package_data] -# Ref: -# https://setuptools.readthedocs.io/en/latest/setuptools.html#options -# (see notes for the asterisk/`*` meaning) -* = - *.so - [pep8] max-line-length=79