Skip to content

fix: skip interpreters with empty output for WSL2 cross-compile#3137

Merged
messense merged 1 commit into
PyO3:mainfrom
plusls:fix_wsl2_xwin
Apr 14, 2026
Merged

fix: skip interpreters with empty output for WSL2 cross-compile#3137
messense merged 1 commit into
PyO3:mainfrom
plusls:fix_wsl2_xwin

Conversation

@plusls

@plusls plusls commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Skip Python interpreters that exit with empty output when checking executable metadata
  • Separate handling for pyenv "command not found" vs empty stderr cases with different warning messages

Problem

When cross-compiling from WSL2 to Windows (e.g. using cargo-xwin), PATH may include Windows Store Python stubs at:

/mnt/c/Users/<user>/AppData/Local/Microsoft/WindowsApps/python.exe

These stub executables exist but don't function as real Python interpreters - they just exit with an error code and produce no output (empty stderr). This caused maturin to fail with:

💥 maturin failed
  Caused by: Trying to get metadata from the python interpreter 'python.exe' failed

Solution

Gracefully skip interpreters with empty stderr output instead of failing the build. This allows cross-compilation workflows (like maturin build --target x86_64-pc-windows-msvc in WSL2) to proceed when using generate-import-lib feature.

Test Plan

Manually tested cross-compilation from WSL2 to Windows with cargo-xwin:

maturin build --release --sdist -o dist --target x86_64-pc-windows-msvc

Fixes #3135

When cross-compiling from WSL2 to Windows, PATH may include Windows Store
Python stubs at /mnt/c/.../WindowsApps/python.exe. These stubs exit with
an error code and produce no output (empty stderr), causing maturin to
fail with "Trying to get metadata from python interpreter failed".

Gracefully skip these stub interpreters instead of failing the build.

@messense messense left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@messense messense enabled auto-merge (squash) April 14, 2026 06:45
@messense messense merged commit 666caaa into PyO3:main Apr 14, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can not cross compile to windows via cargo-xwin in wsl2

2 participants