|
8 | 8 | from textwrap import dedent
|
9 | 9 |
|
10 | 10 | from virtualenv.create.describe import Python3Supports
|
11 |
| -from virtualenv.create.via_global_ref.builtin.ref import PathRefToDest |
| 11 | +from virtualenv.create.via_global_ref.builtin.ref import ExePathRefToDest, PathRefToDest |
12 | 12 | from virtualenv.create.via_global_ref.store import is_store_python
|
13 | 13 |
|
14 | 14 | from .common import CPython, CPythonPosix, CPythonWindows, is_mac_os_framework, is_macos_brew
|
@@ -69,15 +69,47 @@ def sources(cls, interpreter):
|
69 | 69 |
|
70 | 70 | @classmethod
|
71 | 71 | def executables(cls, interpreter):
|
72 |
| - return super().sources(interpreter) |
| 72 | + sources = super().sources(interpreter) |
| 73 | + if interpreter.version_info >= (3, 13): |
| 74 | + # Create new refs with corrected launcher paths |
| 75 | + updated_sources = [] |
| 76 | + for ref in sources: |
| 77 | + if ref.src.name == "python.exe": |
| 78 | + launcher_path = ref.src.with_name("venvlauncher.exe") |
| 79 | + if launcher_path.exists(): |
| 80 | + new_ref = ExePathRefToDest( |
| 81 | + launcher_path, dest=ref.dest, targets=[ref.base, *ref.aliases], must=ref.must, when=ref.when |
| 82 | + ) |
| 83 | + updated_sources.append(new_ref) |
| 84 | + continue |
| 85 | + elif ref.src.name == "pythonw.exe": |
| 86 | + w_launcher_path = ref.src.with_name("venvwlauncher.exe") |
| 87 | + if w_launcher_path.exists(): |
| 88 | + new_ref = ExePathRefToDest( |
| 89 | + w_launcher_path, |
| 90 | + dest=ref.dest, |
| 91 | + targets=[ref.base, *ref.aliases], |
| 92 | + must=ref.must, |
| 93 | + when=ref.when, |
| 94 | + ) |
| 95 | + updated_sources.append(new_ref) |
| 96 | + continue |
| 97 | + # Keep the original ref unchanged |
| 98 | + updated_sources.append(ref) |
| 99 | + return updated_sources |
| 100 | + return sources |
73 | 101 |
|
74 | 102 | @classmethod
|
75 | 103 | def has_shim(cls, interpreter):
|
76 | 104 | return interpreter.version_info.minor >= 7 and cls.shim(interpreter) is not None # noqa: PLR2004
|
77 | 105 |
|
78 | 106 | @classmethod
|
79 | 107 | def shim(cls, interpreter):
|
80 |
| - shim = Path(interpreter.system_stdlib) / "venv" / "scripts" / "nt" / "python.exe" |
| 108 | + root = Path(interpreter.system_stdlib) / "venv" / "scripts" / "nt" |
| 109 | + # Before 3.13 the launcher was called python.exe, after is venvlauncher.exe |
| 110 | + # https://github.com/python/cpython/issues/112984 |
| 111 | + exe_name = "venvlauncher.exe" if interpreter.version_info >= (3, 13) else "python.exe" |
| 112 | + shim = root / exe_name |
81 | 113 | if shim.exists():
|
82 | 114 | return shim
|
83 | 115 | return None
|
|
0 commit comments