MINGW-packages/mingw-w64-python/0088-venv-creation-fixes.patch
2024-11-03 19:29:19 +01:00

53 lines
2.1 KiB
Diff

From 09aed69c644ae3851cf953f8aadc59d1c258991b Mon Sep 17 00:00:00 2001
From: Naveen M K <naveen521kk@gmail.com>
Date: Fri, 23 Jun 2023 20:49:15 +0530
Subject: [PATCH 088/N] venv creation fixes
---
Lib/venv/__init__.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py
index d5dec4a..db2f161 100644
--- a/Lib/venv/__init__.py
+++ b/Lib/venv/__init__.py
@@ -11,7 +11,7 @@ import subprocess
import sys
import sysconfig
import types
-
+from sysconfig import _POSIX_BUILD
CORE_VENV_DEPS = ('pip',)
logger = logging.getLogger(__name__)
@@ -329,7 +329,7 @@ class EnvBuilder:
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
@@ -353,6 +353,12 @@ class EnvBuilder:
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):
@@ -377,6 +383,7 @@ class EnvBuilder:
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)