Skip to content

Commit 914bcc3

Browse files
authored
Merge pull request #9838 from uranusjr/sysconfig-header-with-none-project
Set project name to UNKNOWN when empty
2 parents 75ba96c + 2a009a0 commit 914bcc3

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

news/9838.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix compatibility between distutils and sysconfig when the project name is unknown outside of a virtual environment.

src/pip/_internal/locations/_sysconfig.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,20 @@ def get_scheme(
127127

128128
paths = sysconfig.get_paths(scheme=scheme_name, vars=variables)
129129

130-
# Pip historically uses a special header path in virtual environments.
130+
# Logic here is very arbitrary, we're doing it for compatibility, don't ask.
131+
# 1. Pip historically uses a special header path in virtual environments.
132+
# 2. If the distribution name is not known, distutils uses 'UNKNOWN'. We
133+
# only do the same when not running in a virtual environment because
134+
# pip's historical header path logic (see point 1) did not do this.
131135
if running_under_virtualenv():
132136
if user:
133137
base = variables.get("userbase", sys.prefix)
134138
else:
135139
base = variables.get("base", sys.prefix)
136140
python_xy = f"python{get_major_minor_version()}"
137141
paths["include"] = os.path.join(base, "include", "site", python_xy)
142+
elif not dist_name:
143+
dist_name = "UNKNOWN"
138144

139145
scheme = Scheme(
140146
platlib=paths["platlib"],

0 commit comments

Comments
 (0)