@@ -141,10 +141,9 @@ def create_if_needed(d):
141141 # Issue 21197: create lib64 as a symlink to lib on 64-bit non-OS X POSIX
142142 if ((sys .maxsize > 2 ** 32 ) and (os .name == 'posix' ) and
143143 (sys .platform != 'darwin' )):
144- p = os .path .join (env_dir , 'lib' )
145144 link_path = os .path .join (env_dir , 'lib64' )
146145 if not os .path .exists (link_path ): # Issue #21643
147- os .symlink (p , link_path )
146+ os .symlink ('lib' , link_path )
148147 context .bin_path = binpath = os .path .join (env_dir , binname )
149148 context .bin_name = binname
150149 context .env_exe = os .path .join (binpath , exename )
@@ -178,15 +177,19 @@ def include_binary(self, f):
178177 result = f .startswith ('python' ) and f .endswith ('.exe' )
179178 return result
180179
181- def symlink_or_copy (self , src , dst ):
180+ def symlink_or_copy (self , src , dst , relative_symlinks_ok = False ):
182181 """
183182 Try symlinking a file, and if that fails, fall back to copying.
184183 """
185184 force_copy = not self .symlinks
186185 if not force_copy :
187186 try :
188187 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 )
190193 except Exception : # may need to use a more specific exception
191194 logger .warning ('Unable to symlink %r to %r' , src , dst )
192195 force_copy = True
@@ -201,7 +204,6 @@ def setup_python(self, context):
201204 being processed.
202205 """
203206 binpath = context .bin_path
204- exename = context .python_exe
205207 path = context .env_exe
206208 copier = self .symlink_or_copy
207209 copier (context .executable , path )
@@ -214,7 +216,7 @@ def setup_python(self, context):
214216 if not os .path .exists (path ):
215217 # Issue 18807: make copies if
216218 # symlinks are not wanted
217- copier (context .env_exe , path )
219+ copier (context .env_exe , path , relative_symlinks_ok = True )
218220 if not os .path .islink (path ):
219221 os .chmod (path , 0o755 )
220222 else :
0 commit comments