From d25f6d985b66b8153abee52ad7e6d00f5580d532 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 3 Jul 2024 11:22:23 -0400 Subject: [PATCH] Moved the dependencies to a 'core' extra to avoid dangers with cyclic dependencies at build time. --- newsfragments/2825.removal.rst | 2 +- pyproject.toml | 24 +++++++++++++----------- tools/vendored.py | 12 ++++++++++-- tox.ini | 1 + 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/newsfragments/2825.removal.rst b/newsfragments/2825.removal.rst index 38a9dac9b0..f7a2460d4b 100644 --- a/newsfragments/2825.removal.rst +++ b/newsfragments/2825.removal.rst @@ -1 +1 @@ -Now setuptools declares its own dependencies. Dependencies are still vendored for bootstrapping purposes, but installed dependencies are preferred. Downstream packagers can de-vendor by simply removing the ``setuptools/_vendor`` directory. \ No newline at end of file +Now setuptools declares its own dependencies in the ``core`` extra. Dependencies are still vendored for bootstrapping purposes, but installed dependencies are preferred. Downstream packagers can de-vendor by simply removing the ``setuptools/_vendor`` directory. diff --git a/pyproject.toml b/pyproject.toml index 7c517943a4..b02f3930ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,17 +25,6 @@ classifiers = [ keywords = ["CPAN PyPI distutils eggs package management"] requires-python = ">=3.8" dependencies = [ - "packaging>=24", - "ordered-set>=3.1.1", - "more_itertools>=8.8", - "jaraco.text>=3.7", - "importlib_resources>=5.10.2", - "importlib_metadata>=6", - "tomli>=2.0.1", - "wheel>=0.43.0", - - # pkg_resources - "platformdirs >= 2.6.2", ] [project.urls] @@ -107,6 +96,19 @@ doc = [ ] ssl = [] certs = [] +core = [ + "packaging>=24", + "ordered-set>=3.1.1", + "more_itertools>=8.8", + "jaraco.text>=3.7", + "importlib_resources>=5.10.2", + "importlib_metadata>=6", + "tomli>=2.0.1", + "wheel>=0.43.0", + + # pkg_resources + "platformdirs >= 2.6.2", +] [project.entry-points."distutils.commands"] alias = "setuptools.command.alias:alias" diff --git a/tools/vendored.py b/tools/vendored.py index 5f8a6c0906..2101e7c20f 100644 --- a/tools/vendored.py +++ b/tools/vendored.py @@ -1,4 +1,5 @@ import functools +import re import sys import subprocess @@ -29,11 +30,18 @@ def metadata(): return jaraco.packaging.metadata.load('.') +def upgrade_core(dep): + """ + Remove 'extra == "core"' from any dependency. + """ + return re.sub('''(;| and) extra == ['"]core['"]''', '', dep) + + def load_deps(): """ - Read the dependencies from `.`. + Read the dependencies from `.[core]`. """ - return metadata().get_all('Requires-Dist') + return list(map(upgrade_core, metadata().get_all('Requires-Dist'))) def min_python(): diff --git a/tox.ini b/tox.ini index 8a3f6260b7..00e38fbb9a 100644 --- a/tox.ini +++ b/tox.ini @@ -10,6 +10,7 @@ commands = usedevelop = True extras = test + core pass_env = SETUPTOOLS_USE_DISTUTILS SETUPTOOLS_ENFORCE_DEPRECATION