Skip to content

Commit ca017ca

Browse files
authored
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
2 parents 9311049 + b47da27 commit ca017ca

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

news/1890.bugfix

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

src/pip/_internal/req/req_install.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ def run_egg_info(self):
595595
'Running setup.py (path:%s) egg_info for package from %s',
596596
self.setup_py_path, self.link,
597597
)
598-
script = SETUPTOOLS_SHIM % self.setup_py_path
598+
script = SETUPTOOLS_SHIM.format(self.setup_py_path)
599599
base_cmd = [sys.executable, '-c', script]
600600
if self.isolated:
601601
base_cmd += ["--no-user-cfg"]
@@ -757,7 +757,7 @@ def install_editable(
757757
[
758758
sys.executable,
759759
'-c',
760-
SETUPTOOLS_SHIM % self.setup_py_path
760+
SETUPTOOLS_SHIM.format(self.setup_py_path)
761761
] +
762762
list(global_options) +
763763
['develop', '--no-deps'] +
@@ -1004,7 +1004,7 @@ def get_install_args(
10041004
# type: (...) -> List[str]
10051005
install_args = [sys.executable, "-u"]
10061006
install_args.append('-c')
1007-
install_args.append(SETUPTOOLS_SHIM % self.setup_py_path)
1007+
install_args.append(SETUPTOOLS_SHIM.format(self.setup_py_path))
10081008
install_args += list(global_options) + \
10091009
['install', '--record', record_filename]
10101010
install_args += ['--single-version-externally-managed']

src/pip/_internal/utils/setuptools_build.py

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

src/pip/_internal/wheel.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ def _base_setup_args(self, req):
930930
# virtualenv.
931931
return [
932932
sys.executable, '-u', '-c',
933-
SETUPTOOLS_SHIM % req.setup_py_path,
933+
SETUPTOOLS_SHIM.format(req.setup_py_path)
934934
] + list(self.global_options)
935935

936936
def _build_one_pep517(self, req, tempd, python_tag=None):

0 commit comments

Comments
 (0)