From 9e0122668fb95c2368bac173fc50e2ee3f6ff099 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 28 Oct 2025 22:48:34 +0100 Subject: [PATCH] Move dependency metadata from `setup.cfg` to `pyproject.toml` PR #11643. This is a follow-up to #9951 implementing PEP 621. (cherry picked from commit e1aec0ac94277a8b67092293aeac3c19e17fdd86) --- .github/workflows/ci-cd.yml | 2 +- CHANGES/11643.packaging.rst | 2 ++ Makefile | 2 +- pyproject.toml | 20 ++++++++++++++++++-- requirements/runtime-deps.in | 6 +++--- requirements/sync-direct-runtime-deps.py | 22 ++++++++++++++-------- setup.cfg | 18 ------------------ 7 files changed, 39 insertions(+), 33 deletions(-) create mode 100644 CHANGES/11643.packaging.rst diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 83003b1eaa8..757cfab769f 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -37,7 +37,7 @@ jobs: submodules: true - name: >- Verify that `requirements/runtime-deps.in` - is in sync with `setup.cfg` + is in sync with `pyproject.toml` run: | set -eEuo pipefail make sync-direct-runtime-deps diff --git a/CHANGES/11643.packaging.rst b/CHANGES/11643.packaging.rst new file mode 100644 index 00000000000..8ef91a18788 --- /dev/null +++ b/CHANGES/11643.packaging.rst @@ -0,0 +1,2 @@ +Moved dependency metadata from :file:`setup.cfg` to :file:`pyproject.toml` per :pep:`621` +-- by :user:`cdce8p`. diff --git a/Makefile b/Makefile index af5f7146716..29dd75cd53c 100644 --- a/Makefile +++ b/Makefile @@ -179,5 +179,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 fa6da9c82dd..7856bf4b326 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,12 +32,28 @@ classifiers = [ "Topic :: Internet :: WWW/HTTP", ] requires-python = ">= 3.10" +dependencies = [ + "aiohappyeyeballs >= 2.5.0", + "aiosignal >= 1.4.0", + "async-timeout >= 4.0, < 6.0 ; python_version < '3.11'", + "attrs >= 17.3.0", + "frozenlist >= 1.1.1", + "multidict >=4.5, < 7.0", + "propcache >= 0.2.0", + "yarl >= 1.17.0, < 2.0", +] dynamic = [ - "dependencies", - "optional-dependencies", "version", ] +[project.optional-dependencies] +speedups = [ + "aiodns >= 3.3.0", + "Brotli; platform_python_implementation == 'CPython'", + "brotlicffi; platform_python_implementation != 'CPython'", + "backports.zstd; platform_python_implementation == 'CPython' and python_version < '3.14'", +] + [[project.maintainers]] name = "aiohttp team" email = "team@aiohttp.org" diff --git a/requirements/runtime-deps.in b/requirements/runtime-deps.in index ad8f28e750d..95db17e158d 100644 --- a/requirements/runtime-deps.in +++ b/requirements/runtime-deps.in @@ -1,11 +1,11 @@ -# Extracted from `setup.cfg` via `make sync-direct-runtime-deps` +# Extracted from `pyproject.toml` via `make sync-direct-runtime-deps` aiodns >= 3.3.0 aiohappyeyeballs >= 2.5.0 aiosignal >= 1.4.0 -async-timeout >= 4.0, < 6.0 ; python_version < "3.11" +async-timeout >= 4.0, < 6.0 ; python_version < '3.11' attrs >= 17.3.0 -backports.zstd; platform_python_implementation == 'CPython' and python_version < "3.14" +backports.zstd; platform_python_implementation == 'CPython' and python_version < '3.14' 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..dbe445383c1 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: + raise RuntimeError("Use Python 3.11+ to run 'make sync-direct-runtime-deps'") + +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 4e49e33f304..b1bf1464a11 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,21 +1,3 @@ -[options] -install_requires = - aiohappyeyeballs >= 2.5.0 - aiosignal >= 1.4.0 - async-timeout >= 4.0, < 6.0 ; python_version < "3.11" - attrs >= 17.3.0 - frozenlist >= 1.1.1 - multidict >=4.5, < 7.0 - propcache >= 0.2.0 - yarl >= 1.17.0, < 2.0 - -[options.extras_require] -speedups = - aiodns >= 3.3.0 - Brotli; platform_python_implementation == 'CPython' - brotlicffi; platform_python_implementation != 'CPython' - backports.zstd; platform_python_implementation == 'CPython' and python_version < "3.14" - [pep8] max-line-length=79