Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/9838.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix compatibility between distutils and sysconfig when the project name is unknown outside of a virtual environment.
1 change: 1 addition & 0 deletions news/9839.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix compatibility between distutils and sysconfig when the returned location is a symbolic link.
4 changes: 4 additions & 0 deletions src/pip/_internal/locations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import contextlib
import logging
import pathlib
import sys
Expand Down Expand Up @@ -45,6 +46,9 @@ def _default_base(*, user: bool) -> str:
def _warn_if_mismatch(old: pathlib.Path, new: pathlib.Path, *, key: str) -> bool:
if old == new:
return False
with contextlib.suppress(OSError):
if old.samefile(new):
return False
issue_url = "https://github.com/pypa/pip/issues/9617"
message = (
"Value for %s does not match. Please report this to <%s>"
Expand Down
3 changes: 3 additions & 0 deletions src/pip/_internal/locations/_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,16 @@ def get_scheme(
paths = sysconfig.get_paths(scheme=scheme_name, vars=variables)

# Pip historically uses a special header path in virtual environments.
# Logic here is very arbitrary, we're doing it for compatibility, don't ask.
if running_under_virtualenv():
if user:
base = variables.get("userbase", sys.prefix)
else:
base = variables.get("base", sys.prefix)
python_xy = f"python{get_major_minor_version()}"
paths["include"] = os.path.join(base, "include", "site", python_xy)
elif not dist_name:
dist_name = "UNKNOWN"

scheme = Scheme(
platlib=paths["platlib"],
Expand Down