1111import sys
1212import sysconfig
1313import types
14-
14+ from sysconfig import _POSIX_BUILD
1515
1616CORE_VENV_DEPS = ('pip' , 'setuptools' )
1717logger = logging .getLogger (__name__ )
@@ -301,7 +301,7 @@ def setup_python(self, context):
301301 if not os .path .islink (path ):
302302 os .chmod (path , 0o755 )
303303 else :
304- if self .symlinks :
304+ if self .symlinks and not _POSIX_BUILD :
305305 # For symlinking, we need a complete copy of the root directory
306306 # If symlinks fail, you'll get unnecessary copies of files, but
307307 # we assume that if you've opted into symlinks on Windows then
@@ -325,6 +325,12 @@ def setup_python(self, context):
325325 if os .path .lexists (src ):
326326 copier (src , os .path .join (binpath , suffix ))
327327
328+ if _POSIX_BUILD :
329+ # copy from python/pythonw so the venvlauncher magic in symlink_or_copy triggers
330+ copier (os .path .join (dirname , 'python.exe' ), os .path .join (binpath , 'python3.exe' ))
331+ copier (os .path .join (dirname , 'python.exe' ), os .path .join (binpath , 'python%d.%d.exe' % sys .version_info [:2 ]))
332+ copier (os .path .join (dirname , 'pythonw.exe' ), os .path .join (binpath , 'python3w.exe' ))
333+
328334 if sysconfig .is_python_build ():
329335 # copy init.tcl
330336 for root , dirs , files in os .walk (context .python_dir ):
@@ -349,6 +355,7 @@ def _call_new_python(self, context, *py_args, **kwargs):
349355 env ['VIRTUAL_ENV' ] = context .env_dir
350356 env .pop ('PYTHONHOME' , None )
351357 env .pop ('PYTHONPATH' , None )
358+ env .pop ("MSYSTEM" , None )
352359 kwargs ['cwd' ] = context .env_dir
353360 kwargs ['executable' ] = context .env_exec_cmd
354361 subprocess .check_output (args , ** kwargs )
0 commit comments