Skip to content

Commit 916375d

Browse files
feat: ensure creation of python3.exe and python3 on Windows (#2957)
Signed-off-by: Emre Şafak <[email protected]> Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent 1d7548d commit 916375d

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

docs/changelog/2774.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Ensure python3.exe and python3 on Windows for Python 3. - by :user:`esafak`.

src/virtualenv/create/via_global_ref/builtin/cpython/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ def _executables(cls, interpreter):
3838
# - https://bugs.python.org/issue42013
3939
# - venv
4040
host = cls.host_python(interpreter)
41-
for path in (host.parent / n for n in {"python.exe", host.name}):
41+
names = {"python.exe", host.name}
42+
if interpreter.version_info.major == 3: # noqa: PLR2004
43+
names.update({"python3.exe", "python3"})
44+
for path in (host.parent / n for n in names):
4245
yield host, [path.name], RefMust.COPY, RefWhen.ANY
4346
# for more info on pythonw.exe see https://stackoverflow.com/a/30313091
4447
python_w = host.parent / "pythonw.exe"

tests/unit/create/via_global_ref/builtin/cpython/test_cpython3_win.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,11 @@ def test_no_python_zip_if_not_exists(py_info, mock_files):
9999
sources = tuple(CPython3Windows.sources(interpreter=py_info))
100100
assert python_zip in py_info.path
101101
assert not contains_ref(sources, python_zip)
102+
103+
104+
@pytest.mark.parametrize("py_info_name", ["cpython3_win_embed"])
105+
def test_python3_exe_present(py_info, mock_files):
106+
mock_files(CPYTHON3_PATH, [py_info.system_executable])
107+
sources = tuple(CPython3Windows.sources(interpreter=py_info))
108+
assert contains_exe(sources, py_info.system_executable, "python3.exe")
109+
assert contains_exe(sources, py_info.system_executable, "python3")

0 commit comments

Comments
 (0)