Skip to content

Commit

Permalink
venv creation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
naveen521kk authored and lazka committed Jul 19, 2023
1 parent d415780 commit f6f6352
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Lib/venv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import sys
import sysconfig
import types

from sysconfig import _POSIX_BUILD

CORE_VENV_DEPS = ('pip', 'setuptools')
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -301,7 +301,7 @@ def setup_python(self, context):
if not os.path.islink(path):
os.chmod(path, 0o755)
else:
if self.symlinks:
if self.symlinks and not _POSIX_BUILD:
# For symlinking, we need a complete copy of the root directory
# If symlinks fail, you'll get unnecessary copies of files, but
# we assume that if you've opted into symlinks on Windows then
Expand All @@ -325,6 +325,12 @@ def setup_python(self, context):
if os.path.lexists(src):
copier(src, os.path.join(binpath, suffix))

if _POSIX_BUILD:
# copy from python/pythonw so the venvlauncher magic in symlink_or_copy triggers
copier(os.path.join(dirname, 'python.exe'), os.path.join(binpath, 'python3.exe'))
copier(os.path.join(dirname, 'python.exe'), os.path.join(binpath, 'python%d.%d.exe' % sys.version_info[:2]))
copier(os.path.join(dirname, 'pythonw.exe'), os.path.join(binpath, 'python3w.exe'))

if sysconfig.is_python_build():
# copy init.tcl
for root, dirs, files in os.walk(context.python_dir):
Expand All @@ -349,6 +355,7 @@ def _call_new_python(self, context, *py_args, **kwargs):
env['VIRTUAL_ENV'] = context.env_dir
env.pop('PYTHONHOME', None)
env.pop('PYTHONPATH', None)
env.pop("MSYSTEM", None)
kwargs['cwd'] = context.env_dir
kwargs['executable'] = context.env_exec_cmd
subprocess.check_output(args, **kwargs)
Expand Down

0 comments on commit f6f6352

Please sign in to comment.