Skip to content

Commit 71a7236

Browse files
committed
Reconcile computation of isolated build environment paths
Use the same code to determine isolated environment paths at dependency install time and at environment setup time. We do not care about the exact paths but the paths needs to be consistent at package installation time and environment setup. This should fix all issues observed on platforms that customize the installation schemes, such as Debian and Homebrew, where dependency installation and isolated build environment setup resolved to different paths. See pypa#11598 and pypa#11623.
1 parent 729032d commit 71a7236

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

news/11740.bugfix.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Reconcile computation of isolated build environment paths. Fix all
2+
issues observed on platforms that customize the installation schemes,
3+
such as Debian and Homebrew, where dependency installation and
4+
isolated build environment setup resolved to different paths.

src/pip/_internal/build_env.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,15 @@
99
import textwrap
1010
from collections import OrderedDict
1111
from types import TracebackType
12-
from typing import TYPE_CHECKING, Iterable, List, Optional, Set, Tuple, Type
12+
from typing import TYPE_CHECKING, Iterable, List, Optional, Set, Tuple, Type, Union
1313

1414
from pip._vendor.certifi import where
1515
from pip._vendor.packaging.requirements import Requirement
1616
from pip._vendor.packaging.version import Version
1717

1818
from pip import __file__ as pip_location
1919
from pip._internal.cli.spinners import open_spinner
20-
from pip._internal.locations import (
21-
get_isolated_environment_bin_path,
22-
get_isolated_environment_lib_paths,
23-
get_platlib,
24-
get_purelib,
25-
)
20+
from pip._internal.locations import get_platlib, get_purelib, get_scheme
2621
from pip._internal.metadata import get_default_environment, get_environment
2722
from pip._internal.utils.subprocess import call_subprocess
2823
from pip._internal.utils.temp_dir import TempDirectory, tempdir_kinds
@@ -33,12 +28,17 @@
3328
logger = logging.getLogger(__name__)
3429

3530

31+
def _dedup(a: str, b: str) -> Union[Tuple[str], Tuple[str, str]]:
32+
return (a, b) if a != b else (a,)
33+
34+
3635
class _Prefix:
3736
def __init__(self, path: str) -> None:
3837
self.path = path
3938
self.setup = False
40-
self.bin_dir = get_isolated_environment_bin_path(path)
41-
self.lib_dirs = get_isolated_environment_lib_paths(path)
39+
scheme = get_scheme("", prefix=path)
40+
self.bin_dir = scheme.scripts
41+
self.lib_dirs = _dedup(scheme.purelib, scheme.platlib)
4242

4343

4444
def get_runnable_pip() -> str:

0 commit comments

Comments
 (0)