Skip to content

Find versioned interpreter names like pypy3.11 on Windows - #3325

Merged
messense merged 2 commits into
PyO3:mainfrom
monosans:windows-versioned-interpreter-names
Oct 15, 2026
Merged

messense merged 2 commits into
PyO3:mainfrom
monosans:windows-versioned-interpreter-names

Conversation

@monosans

@monosans monosans commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3324.

On Windows, Rust's Command appends .exe only when the program name has no extension. A versioned interpreter name like pypy3.11 or python3.14t counts as having one (.11, .14t), so -i pypy3.11 was never found on PATH. maturin fell back to the bundled sysconfig, which tags PyPy wheels pp73 (PyPy 8 can't install them), and printed "Failed to determine python platform" twice.

This adds python_command, a drop-in for Command::new that, on Windows, looks up <name>.exe on PATH when the name has no directory part and an extension other than .exe. It replaces Command::new in the metadata query in check_executable and in the two platform probes in target/mod.rs, which had the same problem. If <name>.exe isn't on PATH, the command is created as before, so the py launcher fallback still runs.

Tested on Windows with PyPy from uv python install --no-registry pypy3.11, building test-crates/pyo3-pure with -i pypy3.11:

  • before: the two warnings, then pp311-pypy311_pp73-win_amd64
  • after: no warnings, PyPy found at ...\pypy-3.11.16-windows-x86_64-none\pypy3.11.exe, pp311-pypy311_pp80-win_amd64
  • -i pypy3.11.exe behaves the same as before, and with the interpreter not on PATH the result is the same as before the change.

cargo fmt is clean, cargo test --lib python_interpreter and cargo test --lib target:: pass, and the change adds no clippy warnings.

On Windows, Rust's `Command` appends `.exe` only when the program name
has no extension, and `pypy3.11` or `python3.14t` count as having one
(`.11`, `.14t`). So `-i pypy3.11` was never found on PATH, and maturin
fell back to the bundled sysconfig, which tags PyPy wheels `pp73` (PyPy 8
can't install them), after printing "Failed to determine python platform"
twice.

Add `python_command`, which on Windows looks up `<name>.exe` on PATH for
such names, and use it for the metadata query in `check_executable` and
the two platform probes in `target/mod.rs`.
@monosans
monosans force-pushed the windows-versioned-interpreter-names branch from bb17912 to 80befad Compare October 14, 2026 23:24
New RustSec advisories make `cargo deny check` fail, and with it the Lint
job of every pull request:

- `rustls` 0.23.45 is affected by RUSTSEC-2026-0346, -0347, -0348 and
  -0349. Update it to 0.23.46, which fixes all four.
- `ruzstd` 0.8.2 is affected by RUSTSEC-2026-0344, fixed only in 0.9.1.
  It comes in through `object` 0.38, which `arwen` pins, so it cannot be
  updated until `arwen` updates `object`. Ignore the advisory with that
  reason: maturin only uses `arwen` to rewrite the Mach-O load commands of
  libraries it repairs, not to decompress untrusted zstd data.
@monosans

Copy link
Copy Markdown
Contributor Author

Lint was failing on new RustSec advisories for rustls and ruzstd, unrelated to this change. The fix is in #3328; I cherry-picked it here so CI can run green. It will drop out of the diff once #3328 lands and this branch is updated from main.

messense pushed a commit that referenced this pull request Oct 15, 2026
New RustSec advisories make `cargo deny check` fail, and with it the
Lint job of every pull request (e.g. #3325).

- `rustls` 0.23.45 is affected by RUSTSEC-2026-0346, -0347, -0348 and
-0349. This updates it to 0.23.46, which fixes all four.
- `ruzstd` 0.8.2 is affected by RUSTSEC-2026-0344, fixed only in 0.9.1.
It comes in through `object` 0.38, which `arwen` 0.0.5 pins, so it
cannot be updated until `arwen` updates `object`. This ignores the
advisory with that reason in `deny.toml`: maturin only uses `arwen` to
rewrite the Mach-O load commands of libraries it repairs, not to
decompress untrusted zstd data.

`cargo deny --all-features check` now reports `advisories ok, bans ok,
licenses ok, sources ok`.
@messense
messense merged commit 5718440 into PyO3:main Oct 15, 2026
45 checks passed
monosans added a commit to monosans/pyromark that referenced this pull request Oct 30, 2026
* Revert PyPy .exe workaround on Windows

Since PyO3/maturin#3325, maturin finds `pypy3.X` on PATH on Windows
instead of falling back to its bundled sysconfig (pp73).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Revert workaround: no PyPy 3.12 in the manylinux 2_17 images

Since PyO3/maturin#3343, maturin tags PyPy 3.12 built from its bundled
sysconfig pp80, so the manylinux2014 images can build PyPy 3.12 again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci: bump maturin to 1.16.0

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci: test the manylinux 2_17 PyPy 3.12 wheel on PyPy

maturin builds this wheel from its bundled sysconfig, since the manylinux2014 images have no PyPy 3.12, so no interpreter checks it at build time. Run pytest on it with PyPy 3.12 and skip the tests that rely on CPython's garbage collector and introspection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
monosans added a commit to monosans/mkdocs-minify-html-plugin that referenced this pull request Oct 30, 2026
* Revert PyPy .exe workaround on Windows

Since PyO3/maturin#3325, maturin finds `pypy3.X` on PATH on Windows
instead of falling back to its bundled sysconfig (pp73).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Revert workaround: no PyPy 3.12 in the manylinux 2_17 images

Since PyO3/maturin#3343, maturin tags PyPy 3.12 built from its bundled
sysconfig pp80, so the manylinux2014 images can build PyPy 3.12 again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci: bump maturin to 1.16.0

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci: smoke-test the manylinux 2_17 PyPy 3.12 wheel on PyPy

maturin builds this wheel from its bundled sysconfig, since the manylinux2014 images have no PyPy 3.12, so no interpreter checks it at build time. Install it on PyPy 3.12 and minify a page with the default options.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: add a pytest suite

Build a small site with and without the plugin and check that pages and HTML templates are minified, that sitemap.xml is left alone, that options set in mkdocs.yml reach minify-html, and that the README lists every option with its default. Run it in CI on the manylinux 2_28 x86_64 wheel, as in pyromark.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci: run pytest on the manylinux 2_17 PyPy 3.12 wheel instead of a smoke test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

Windows: -i pypy3.11 / -i python3.13 not found on PATH, maturin silently uses bundled sysconfig (wrong pp73 tag)

2 participants