diff options
author | Thomas Kluyver <thomas@kluyver.me.uk> | 2020-08-06 08:51:10 +0100 |
---|---|---|
committer | Thomas Kluyver <thomas@kluyver.me.uk> | 2020-08-06 08:51:10 +0100 |
commit | fe79e6ca8ef48edb3ee2ea42b3021aa7de963a49 (patch) | |
tree | f65b3994ec18211f30f6e2abe46df7dbdd6388e0 /setuptools/build_meta.py | |
parent | 5e60dc50e540a942aeb558aabe7d92ab7eb13d4b (diff) | |
download | python-setuptools-git-fe79e6ca8ef48edb3ee2ea42b3021aa7de963a49.tar.gz |
Don't install setup_requires when run as a PEP-517 backend.
Under PEP-517, installing build dependencies is up to the frontend.
Closes gh-2303
Diffstat (limited to 'setuptools/build_meta.py')
-rw-r--r-- | setuptools/build_meta.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/setuptools/build_meta.py b/setuptools/build_meta.py index 46266814..49b4cc28 100644 --- a/setuptools/build_meta.py +++ b/setuptools/build_meta.py @@ -75,6 +75,22 @@ class Distribution(setuptools.dist.Distribution): distutils.core.Distribution = orig +@contextlib.contextmanager +def no_install_setup_requires(): + """Temporarily disable installing setup_requires + + Under PEP 517, the backend reports build dependencies to the frontend, + and the frontend is responsible for ensuring they're installed. + So setuptools (acting as a backend) should not try to install them. + """ + orig = setuptools._install_setup_requires + setuptools._install_setup_requires = lambda attrs: None + try: + yield + finally: + setuptools._install_setup_requires = orig + + def _to_str(s): """ Convert a filename to a string (on Python 2, explicitly @@ -139,7 +155,8 @@ class _BuildMetaBackend(object): with _open_setup_script(__file__) as f: code = f.read().replace(r'\r\n', r'\n') - exec(compile(code, __file__, 'exec'), locals()) + with no_install_setup_requires(): + exec(compile(code, __file__, 'exec'), locals()) def get_requires_for_build_wheel(self, config_settings=None): config_settings = self._fix_config(config_settings) |