Skip to content

Commit

Permalink
Double-escape paths on Windows
Browse files Browse the repository at this point in the history
This helps ensure that they aren't improperly handled due to the newer
string-in-string design for the setuptools invocation script.
  • Loading branch information
pradyunsg committed Jan 25, 2022
1 parent 2e8e5ad commit d39a252
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/pip/_internal/utils/setuptools_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from typing import List, Optional, Sequence

# Shim to wrap setup.py invocation with setuptools
# Note that __file__ is handled via two {!r} *and* %r, to ensure that paths on
# Windows are correctly handled (it should be "C:\\Users" not "C:\Users").
_SETUPTOOLS_SHIM = textwrap.dedent(
"""
exec(compile('''
Expand All @@ -27,7 +29,7 @@
)
sys.exit(1)
__file__ = {!r}
__file__ = %r
sys.argv[0] = __file__
if os.path.exists(__file__):
Expand All @@ -39,7 +41,7 @@
setup_py_code = "from setuptools import setup; setup()"
exec(compile(setup_py_code, filename, "exec"))
''', "<pip-setuptools-caller>", "exec"))
''' % ({!r},), "<pip-setuptools-caller>", "exec"))
"""
).rstrip()

Expand Down

0 comments on commit d39a252

Please sign in to comment.