Skip to content

Commit

Permalink
Fix invalid header path when --root is set
Browse files Browse the repository at this point in the history
When we invoke setuptools with a `--root`, the header directory we take
from the Scheme object already contains the root as a prefix. Passing
both `--root` and `--install-headers` will result in setuptools adding
the root prefix twice in the header path.

As the Scheme object already has all directories relative to `--root`,
we can pass these separately with the `--install-*` setuptools
arguments and drop the `--root` argument.
  • Loading branch information
lkollar committed Sep 15, 2020
1 parent a13f201 commit 4479542
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/pip/_internal/operations/install/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ def install(
record_filename=record_filename,
root=root,
prefix=prefix,
header_dir=header_dir,
home=home,
use_user_site=use_user_site,
no_user_config=isolated,
pycompile=pycompile,
scheme=scheme
)

runner = runner_with_spinner_message(
Expand Down Expand Up @@ -103,7 +103,7 @@ def prepend_root(path):
for line in record_lines:
directory = os.path.dirname(line)
if directory.endswith('.egg-info'):
egg_info_dir = prepend_root(directory)
egg_info_dir = directory
break
else:
message = (
Expand Down
16 changes: 9 additions & 7 deletions src/pip/_internal/utils/setuptools_build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys

from pip._internal.models.scheme import Scheme
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
Expand Down Expand Up @@ -140,11 +141,11 @@ def make_setuptools_install_args(
record_filename, # type: str
root, # type: Optional[str]
prefix, # type: Optional[str]
header_dir, # type: Optional[str]
home, # type: Optional[str]
use_user_site, # type: bool
no_user_config, # type: bool
pycompile # type: bool
pycompile, # type: bool
scheme, # type: Scheme
):
# type: (...) -> List[str]
assert not (use_user_site and prefix)
Expand All @@ -159,8 +160,12 @@ def make_setuptools_install_args(
args += ["install", "--record", record_filename]
args += ["--single-version-externally-managed"]

if root is not None:
args += ["--root", root]
args += ["--install-purelib", scheme.purelib,
"--install-platlib", scheme.platlib,
"--install-headers", scheme.headers,
"--install-scripts", scheme.scripts,
"--install-data", scheme.data]

if prefix is not None:
args += ["--prefix", prefix]
if home is not None:
Expand All @@ -173,9 +178,6 @@ def make_setuptools_install_args(
else:
args += ["--no-compile"]

if header_dir:
args += ["--install-headers", header_dir]

args += install_options

return args

0 comments on commit 4479542

Please sign in to comment.