@@ -81,8 +81,14 @@ def distutils_scheme(
81
81
scheme .update (dict (purelib = i .install_lib , platlib = i .install_lib ))
82
82
83
83
if running_under_virtualenv ():
84
+ if home :
85
+ prefix = home
86
+ elif user :
87
+ prefix = i .install_userbase # type: ignore
88
+ else :
89
+ prefix = i .prefix
84
90
scheme ["headers" ] = os .path .join (
85
- i . prefix ,
91
+ prefix ,
86
92
"include" ,
87
93
"site" ,
88
94
f"python{ get_major_minor_version ()} " ,
@@ -91,10 +97,7 @@ def distutils_scheme(
91
97
92
98
if root is not None :
93
99
path_no_drive = os .path .splitdrive (os .path .abspath (scheme ["headers" ]))[1 ]
94
- scheme ["headers" ] = os .path .join (
95
- root ,
96
- path_no_drive [1 :],
97
- )
100
+ scheme ["headers" ] = os .path .join (root , path_no_drive [1 :])
98
101
99
102
return scheme
100
103
@@ -135,17 +138,20 @@ def get_scheme(
135
138
136
139
137
140
def get_bin_prefix () -> str :
141
+ # XXX: In old virtualenv versions, sys.prefix can contain '..' components,
142
+ # so we need to call normpath to eliminate them.
143
+ prefix = os .path .normpath (sys .prefix )
138
144
if WINDOWS :
139
- bin_py = os .path .join (sys . prefix , "Scripts" )
145
+ bin_py = os .path .join (prefix , "Scripts" )
140
146
# buildout uses 'bin' on Windows too?
141
147
if not os .path .exists (bin_py ):
142
- bin_py = os .path .join (sys . prefix , "bin" )
148
+ bin_py = os .path .join (prefix , "bin" )
143
149
return bin_py
144
150
# Forcing to use /usr/local/bin for standard macOS framework installs
145
151
# Also log to ~/Library/Logs/ for use with the Console.app log viewer
146
- if sys .platform [:6 ] == "darwin" and sys . prefix [:16 ] == "/System/Library/" :
152
+ if sys .platform [:6 ] == "darwin" and prefix [:16 ] == "/System/Library/" :
147
153
return "/usr/local/bin"
148
- return os .path .join (sys . prefix , "bin" )
154
+ return os .path .join (prefix , "bin" )
149
155
150
156
151
157
def get_purelib () -> str :
0 commit comments