Skip to content

Install python.exe into Windows venvs for console scripts - #410

Draft
agriyakhetarpal wants to merge 1 commit into
test-venvs-on-uv-managed-python-installationsfrom
windows-console-scripts
Draft

Install python.exe into Windows venvs for console scripts#410
agriyakhetarpal wants to merge 1 commit into
test-venvs-on-uv-managed-python-installationsfrom
windows-console-scripts

Conversation

@agriyakhetarpal

Copy link
Copy Markdown
Member

Split off from #409. I have submitted this via gh stack submit (i.e., the GitHub Stacked PRs preview that I applied to and we received). A Pyodide venv on Windows has not had our .exe interpreter because _create_python_symlink deleted every python*.exe that virtualenv created and put .bat symlinks in their place. The launcher that pip generates for a console script refuses to invoke anything that is not an .exe, so no installed script could run.

The idea here is that we already ship a python.exe shim that forwards to python.bat, so we can now copy that into the venv and point pip_wrapper.get_executable at it. It is a copy rather than a symlink because the shim resolves its own path before looking for python.bat beside it, so a symlink would send it to the dist directory and lose the venv.

The shim currently mangles any paths holding a space, for which I created pyodide/pyodide#6381 - it would be good to have that in Pyodide 314.0.4 release but it's not a blocker here because our Windows support is pretty much experimental anyway


Stack created with GitHub Stacks CLIGive Feedback 💬

A Pyodide venv on Windows had no .exe interpreter: _create_python_symlink
deleted every python*.exe virtualenv created and put .bat symlinks in
their place. The launcher pip generates for a console script refuses to
invoke anything that is not an .exe, so no installed script could run.

Pyodide already ships a python.exe shim that forwards to python.bat, so
copy that into the venv and point pip_wrapper.get_executable at it. Copy
rather than symlink: the shim resolves its own path before looking for
python.bat beside it, so a symlink would send it to the dist directory
and lose the venv.

The shim mangles paths holding a space until pyodide/pyodide#6381 is
released, so the Windows venv test and the CI step that builds a venv
outside the workspace both avoid one for now, with TODOs to restore them.

This reapplies what the previous commit on the base branch reverted.
@agriyakhetarpal agriyakhetarpal added the integration This PR will run the integration tests. This label can be used as a persistent marker to do so. label Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration This PR will run the integration tests. This label can be used as a persistent marker to do so.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant