Skip to content

Commit 36e1486

Browse files
committed
Fix isolated environment scripts path on Debian
The scripts path was looked up passing explicitly the scheme to be used using "nt" on Windows and "posix_prefix" everywhere else. However, when the isolated build environment is created, packages are installed using the default scheme for the platform. On most platforms this works because normally "nt" and "posix_prefix" are the default schemes. However, Debian customizes sysconfig to use a "posix_local" scheme by default and under this scheme the scripts path does not match the one of the "posix_prefix" scheme. This results in scripts installed as part of the build dependencies not to be found during the build, as reported here mesonbuild/meson-python#109 and here https://bugs.debian.org/1019293. The problem can be solved omitting to specify a scheme when looking up the scripts path. To future proof the path lookup, use the "venv" scheme if available as done in pypa#11598. For uniformity use similar functions as used to lookup the library paths.
1 parent 5f3f592 commit 36e1486

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

news/11623.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix scripts path in isolated build environment on Debian.

src/pip/_internal/build_env.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from pip import __file__ as pip_location
2020
from pip._internal.cli.spinners import open_spinner
2121
from pip._internal.locations import (
22+
get_isolated_environment_bin_path,
2223
get_isolated_environment_lib_paths,
2324
get_platlib,
2425
get_purelib,
@@ -37,10 +38,7 @@ class _Prefix:
3738
def __init__(self, path: str) -> None:
3839
self.path = path
3940
self.setup = False
40-
self.bin_dir = get_paths(
41-
"nt" if os.name == "nt" else "posix_prefix",
42-
vars={"base": path, "platbase": path},
43-
)["scripts"]
41+
self.bin_dir = get_isolated_environment_bin_path(path)
4442
self.lib_dirs = get_isolated_environment_lib_paths(path)
4543

4644

src/pip/_internal/locations/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"get_major_minor_version",
2929
"get_platlib",
3030
"get_isolated_environment_lib_paths",
31+
"get_isolated_environment_bin_path",
3132
"get_purelib",
3233
"get_scheme",
3334
"get_src_prefix",
@@ -526,3 +527,7 @@ def get_isolated_environment_lib_paths(prefix: str) -> List[str]:
526527
_log_context(prefix=prefix)
527528

528529
return old_lib_paths
530+
531+
532+
def get_isolated_environmemt_bin_path(prefix: str) -> str:
533+
return _sysconfig.get_isolated_environment_bin_path(prefix)

src/pip/_internal/locations/_sysconfig.py

+9
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,12 @@ def get_isolated_environment_lib_paths(prefix: str) -> typing.Tuple[str, str]:
220220
else:
221221
paths = sysconfig.get_paths(vars=vars)
222222
return (paths["purelib"], paths["platlib"])
223+
224+
225+
def get_isolated_environmemt_bin_path(prefix: str) -> str:
226+
vars = {"base": prefix, "platbase": prefix}
227+
if "venv" in sysconfig.get_scheme_names():
228+
paths = sysconfig.get_paths(vars=vars, scheme="venv")
229+
else:
230+
paths = sysconfig.get_paths(vars=vars)
231+
return paths["scripts"]

0 commit comments

Comments
 (0)