@@ -141,10 +141,9 @@ def create_if_needed(d):
141
141
# Issue 21197: create lib64 as a symlink to lib on 64-bit non-OS X POSIX
142
142
if ((sys .maxsize > 2 ** 32 ) and (os .name == 'posix' ) and
143
143
(sys .platform != 'darwin' )):
144
- p = os .path .join (env_dir , 'lib' )
145
144
link_path = os .path .join (env_dir , 'lib64' )
146
145
if not os .path .exists (link_path ): # Issue #21643
147
- os .symlink (p , link_path )
146
+ os .symlink ('lib' , link_path )
148
147
context .bin_path = binpath = os .path .join (env_dir , binname )
149
148
context .bin_name = binname
150
149
context .env_exe = os .path .join (binpath , exename )
@@ -178,15 +177,19 @@ def include_binary(self, f):
178
177
result = f .startswith ('python' ) and f .endswith ('.exe' )
179
178
return result
180
179
181
- def symlink_or_copy (self , src , dst ):
180
+ def symlink_or_copy (self , src , dst , relative_symlinks_ok = False ):
182
181
"""
183
182
Try symlinking a file, and if that fails, fall back to copying.
184
183
"""
185
184
force_copy = not self .symlinks
186
185
if not force_copy :
187
186
try :
188
187
if not os .path .islink (dst ): # can't link to itself!
189
- os .symlink (src , dst )
188
+ if relative_symlinks_ok :
189
+ assert os .path .dirname (src ) == os .path .dirname (dst )
190
+ os .symlink (os .path .basename (src ), dst )
191
+ else :
192
+ os .symlink (src , dst )
190
193
except Exception : # may need to use a more specific exception
191
194
logger .warning ('Unable to symlink %r to %r' , src , dst )
192
195
force_copy = True
@@ -201,7 +204,6 @@ def setup_python(self, context):
201
204
being processed.
202
205
"""
203
206
binpath = context .bin_path
204
- exename = context .python_exe
205
207
path = context .env_exe
206
208
copier = self .symlink_or_copy
207
209
copier (context .executable , path )
@@ -214,7 +216,7 @@ def setup_python(self, context):
214
216
if not os .path .exists (path ):
215
217
# Issue 18807: make copies if
216
218
# symlinks are not wanted
217
- copier (context .env_exe , path )
219
+ copier (context .env_exe , path , relative_symlinks_ok = True )
218
220
if not os .path .islink (path ):
219
221
os .chmod (path , 0o755 )
220
222
else :
0 commit comments