diff options
| -rw-r--r-- | changelog.d/2158.misc.rst | 1 | ||||
| -rw-r--r-- | setuptools/__init__.py | 25 |
2 files changed, 22 insertions, 4 deletions
diff --git a/changelog.d/2158.misc.rst b/changelog.d/2158.misc.rst new file mode 100644 index 00000000..16a5a504 --- /dev/null +++ b/changelog.d/2158.misc.rst @@ -0,0 +1 @@ +Avoid loading working set during ``Distribution.finalize_options`` prior to invoking ``_install_setup_requires``, broken since v42.0.0. diff --git a/setuptools/__init__.py b/setuptools/__init__.py index a71b2bbd..9d8ae1ed 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -129,10 +129,27 @@ if PY3: def _install_setup_requires(attrs): # Note: do not use `setuptools.Distribution` directly, as # our PEP 517 backend patch `distutils.core.Distribution`. - dist = distutils.core.Distribution(dict( - (k, v) for k, v in attrs.items() - if k in ('dependency_links', 'setup_requires') - )) + class MinimalDistribution(distutils.core.Distribution): + """ + A minimal version of a distribution for supporting the + fetch_build_eggs interface. + """ + def __init__(self, attrs): + _incl = 'dependency_links', 'setup_requires' + filtered = { + k: attrs[k] + for k in set(_incl) & set(attrs) + } + distutils.core.Distribution.__init__(self, filtered) + + def finalize_options(self): + """ + Disable finalize_options to avoid building the working set. + Ref #2158. + """ + + dist = MinimalDistribution(attrs) + # Honor setup.cfg's options. dist.parse_config_files(ignore_option_errors=True) if dist.setup_requires: |
