From 4479542b6f8252e9a2f516154ed977d1ee902b77 Mon Sep 17 00:00:00 2001 From: Laszlo Kiss-Kollar Date: Tue, 15 Sep 2020 20:50:53 +0100 Subject: [PATCH] Fix invalid header path when `--root` is set 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. --- src/pip/_internal/operations/install/legacy.py | 4 ++-- src/pip/_internal/utils/setuptools_build.py | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/pip/_internal/operations/install/legacy.py b/src/pip/_internal/operations/install/legacy.py index 87227d5fed6..fd231cb7ceb 100644 --- a/src/pip/_internal/operations/install/legacy.py +++ b/src/pip/_internal/operations/install/legacy.py @@ -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( @@ -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 = ( diff --git a/src/pip/_internal/utils/setuptools_build.py b/src/pip/_internal/utils/setuptools_build.py index 2a664b00703..e3c354f0ff7 100644 --- a/src/pip/_internal/utils/setuptools_build.py +++ b/src/pip/_internal/utils/setuptools_build.py @@ -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: @@ -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) @@ -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: @@ -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