From c16a54766069fb3546d683529895cd548fecd830 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Fri, 8 Sep 2023 18:36:25 +0100 Subject: [PATCH] Prevent install_requires and extras_require to not be set in dist --- setuptools/config/_apply_pyprojecttoml.py | 2 +- setuptools/dist.py | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/setuptools/config/_apply_pyprojecttoml.py b/setuptools/config/_apply_pyprojecttoml.py index 4b8f803c1b..b6443308bf 100644 --- a/setuptools/config/_apply_pyprojecttoml.py +++ b/setuptools/config/_apply_pyprojecttoml.py @@ -125,7 +125,7 @@ def _set_config(dist: "Distribution", field: str, value: Any): setter(value) elif hasattr(dist.metadata, field) or field in SETUPTOOLS_PATCHES: setattr(dist.metadata, field, value) - else: + if hasattr(dist, field): setattr(dist, field, value) diff --git a/setuptools/dist.py b/setuptools/dist.py index 445c3a6856..2672f928d5 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -296,14 +296,11 @@ def __init__(self, attrs=None): self.setup_requires = attrs.pop('setup_requires', []) for ep in metadata.entry_points(group='distutils.setup_keywords'): vars(self).setdefault(ep.name, None) - _Distribution.__init__( - self, - { - k: v - for k, v in attrs.items() - if k not in self._DISTUTILS_UNSUPPORTED_METADATA - }, - ) + + metadata_only = set(self._DISTUTILS_UNSUPPORTED_METADATA) + metadata_only -= {"install_requires", "extras_require"} + dist_attrs = {k: v for k, v in attrs.items() if k not in metadata_only} + _Distribution.__init__(self, dist_attrs) # Private API (setuptools-use only, not restricted to Distribution) # Stores files that are referenced by the configuration and need to be in the