Merge pull request #5936 from bertilhatt/subprocess_invocation_out_setuptools_args

Fix #1890: set sys.argv[0] to the setup.py path in the setuptools shim
This commit is contained in:
Chris Jerdonek 2019-07-07 19:34:20 -07:00 committed by GitHub
commit ca017ca8a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 5 deletions

2
news/1890.bugfix Normal file
View File

@ -0,0 +1,2 @@
Set ``sys.argv[0]`` to the underlying ``setup.py`` when invoking ``setup.py``
via the setuptools shim so setuptools doesn't think the path is ``-c``.

View File

@ -595,7 +595,7 @@ class InstallRequirement(object):
'Running setup.py (path:%s) egg_info for package from %s',
self.setup_py_path, self.link,
)
script = SETUPTOOLS_SHIM % self.setup_py_path
script = SETUPTOOLS_SHIM.format(self.setup_py_path)
base_cmd = [sys.executable, '-c', script]
if self.isolated:
base_cmd += ["--no-user-cfg"]
@ -757,7 +757,7 @@ class InstallRequirement(object):
[
sys.executable,
'-c',
SETUPTOOLS_SHIM % self.setup_py_path
SETUPTOOLS_SHIM.format(self.setup_py_path)
] +
list(global_options) +
['develop', '--no-deps'] +
@ -1004,7 +1004,7 @@ class InstallRequirement(object):
# type: (...) -> List[str]
install_args = [sys.executable, "-u"]
install_args.append('-c')
install_args.append(SETUPTOOLS_SHIM % self.setup_py_path)
install_args.append(SETUPTOOLS_SHIM.format(self.setup_py_path))
install_args += list(global_options) + \
['install', '--record', record_filename]
install_args += ['--single-version-externally-managed']

View File

@ -1,6 +1,11 @@
# Shim to wrap setup.py invocation with setuptools
#
# We set sys.argv[0] to the path to the underlying setup.py file so
# setuptools / distutils don't take the path to the setup.py to be "-c" when
# invoking via the shim. This avoids e.g. the following manifest_maker
# warning: "warning: manifest_maker: standard file '-c' not found".
SETUPTOOLS_SHIM = (
"import setuptools, tokenize;__file__=%r;"
"import sys, setuptools, tokenize; sys.argv[0] = {0!r}; __file__={0!r};"
"f=getattr(tokenize, 'open', open)(__file__);"
"code=f.read().replace('\\r\\n', '\\n');"
"f.close();"

View File

@ -930,7 +930,7 @@ class WheelBuilder(object):
# virtualenv.
return [
sys.executable, '-u', '-c',
SETUPTOOLS_SHIM % req.setup_py_path,
SETUPTOOLS_SHIM.format(req.setup_py_path)
] + list(self.global_options)
def _build_one_pep517(self, req, tempd, python_tag=None):