From de64f1ba443bd4d784b6356fe48e49b8be27fdff Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Thu, 24 Sep 2026 01:46:33 +0000 Subject: [PATCH] ruff-format: CI green on both legs, mark ready for review PR #2198's first CI run only produced a cp314t job (the include-only tag/build keys collapsed the matrix onto one combination - gotcha 402), and that job's smoke test probed the maturin package shim's __file__ instead of the compiled submodule (gotcha 308's shape, without a name collision). Both fixed on the branch; run 35941432233 is green on cp38-abi3 and cp314t plus the publish dry run. Add gotcha 558: gotcha 308's sys.modules probe is the correct fix for *any* pure-Rust maturin project's __file__, not only once a name collision raises AttributeError - the wrap into a generated package is unconditional and interpreter-agnostic. Also record the queue-status update for ruff-format. --- .queue.yml | 4 +-- .../references/gotchas-index.md | 1 + .../gotchas/compiled-vs-pure-detection.md | 33 +++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/.queue.yml b/.queue.yml index 41ed7ed2675..eb14e0896e8 100644 --- a/.queue.yml +++ b/.queue.yml @@ -8427,9 +8427,9 @@ packages: version: 0.5.4 home: https://github.com/reflex-dev/ruff-format repo: https://github.com/reflex-dev/ruff-format - status: ci-running + status: ci-green pr: https://github.com/riseproject-dev/python-wheels/pull/2198 - notes: '20 Linux wheels upstream (abi: cp314,cp38); no riscv64 on PyPI or pypi.riseproject.dev. FEASIBLE and ported: a PyO3/maturin extension (pyo3 abi3-py38 unconditional in Cargo.toml) that vendors ruff_python_parser/ruff_python_formatter from astral-sh/ruff.git as Cargo git dependencies -- it has no runtime Python dependency on the `ruff` PyPI package, so the initial concern about ruff''s own riscv64 status was a non-issue (same shape as complexipy/chalkpy-rs, already ported). Local cargo check --locked --target riscv64gc-unknown-linux-gnu passes clean. Matrix: cp38-abi3 (built on cp39, image floor) + cp314t. Upstream ships no test suite; CIBW_TEST_COMMAND exercises is_valid_syntax/parse_code/format_string against outputs verified with the real ruff CLI locally. PR #2198 open, CI dispatched.' + notes: '20 Linux wheels upstream (abi: cp314,cp38); no riscv64 on PyPI or pypi.riseproject.dev. FEASIBLE and ported: a PyO3/maturin extension (pyo3 abi3-py38 unconditional in Cargo.toml) that vendors ruff_python_parser/ruff_python_formatter from astral-sh/ruff.git as Cargo git dependencies -- it has no runtime Python dependency on the `ruff` PyPI package, so the initial concern about ruff''s own riscv64 status was a non-issue (same shape as complexipy/chalkpy-rs, already ported). Local cargo check --locked --target riscv64gc-unknown-linux-gnu passes clean. Matrix: cp38-abi3 (built on cp39, image floor) + cp314t. First CI run only produced a cp314t job and failed there: the include-only tag/build keys collapsed the matrix onto one combination (gotcha 402 shape) and the smoke test probed the maturin package shim''s __file__ instead of the compiled submodule (gotcha 308 shape, generalized in new gotcha 558 to apply unconditionally to any pure-Rust maturin project, not only on a name collision). Fixed both: tag: [cp38-abi3, cp314t] added as a real matrix dimension, and the probe rewritten as sys.modules[''ruff_format.ruff_format''].__file__. Run 35941432233 green on both build legs plus the publish dry run. PR #2198 ready for review.' - pkg: arro3-io version: 0.8.2 home: https://kylebarron.dev/arro3 diff --git a/skills/python-project-porting/references/gotchas-index.md b/skills/python-project-porting/references/gotchas-index.md index c2cde504e27..c50a76dcd79 100644 --- a/skills/python-project-porting/references/gotchas-index.md +++ b/skills/python-project-porting/references/gotchas-index.md @@ -912,6 +912,7 @@ The porting gotchas (546 of them) live in [`references/gotchas/`](gotchas/), spl - **292** — Gotcha 81's "diff the wheel `size` field" test can pass on a real per-arch binary - **295** — A require-extension knob that reaches the container correctly (gotcha 129's - **308** — A maturin shim whose star-import name collides with the compiled submodule's +- **558** — A pure-Rust maturin project's top-level `__file__` never points at the `.so` — - **398** — Reproducing a `py3-none-` wheel takes an explicit retag — setuptools' - **457** — On cp314t our registry can hand a package a *compiled* dependency wheel where - **510** — A cffi *ABI-mode* payload keeps its `py3-none` tag through `auditwheel repair` — diff --git a/skills/python-project-porting/references/gotchas/compiled-vs-pure-detection.md b/skills/python-project-porting/references/gotchas/compiled-vs-pure-detection.md index da0fb0a2d90..21a9178f9cb 100644 --- a/skills/python-project-porting/references/gotchas/compiled-vs-pure-detection.md +++ b/skills/python-project-porting/references/gotchas/compiled-vs-pure-detection.md @@ -20,6 +20,7 @@ To pull up one entry: `grep -n '^N\. ' references/gotchas/compiled-vs-pure-detec - **292** — Gotcha 81's "diff the wheel `size` field" test can pass on a real per-arch binary - **295** — A require-extension knob that reaches the container correctly (gotcha 129's - **308** — A maturin shim whose star-import name collides with the compiled submodule's +- **558** — A pure-Rust maturin project's top-level `__file__` never points at the `.so` — - **398** — Reproducing a `py3-none-` wheel takes an explicit retag — setuptools' - **457** — On cp314t our registry can hand a package a *compiled* dependency wheel where - **510** — A cffi *ABI-mode* payload keeps its `py3-none` tag through `auditwheel repair` — @@ -395,6 +396,38 @@ To pull up one entry: `grep -n '^N\. ' references/gotchas/compiled-vs-pure-detec `murmurhash2/murmurhash2.abi3.so` next to each other names both the shim and the real extension before a single CI cycle is spent on the wrong probe. +558. **A pure-Rust maturin project's top-level `__file__` never points at the `.so` — not + just when a name collides with gotcha 308's shim (the ruff-format case; see + `build-ruff-format.yml`).** Gotcha 308 covers a *collision*: the generated + `__init__.py`'s `from . import *` overwriting the submodule attribute with a + same-named exported function, which raises `AttributeError` on `.__file__`. A pure-Rust + maturin crate with no such collision fails the same probe more quietly: `import + ruff_format as m; m.__file__` resolves fine, but to the generated + `ruff_format/__init__.py` (a `.py` file) — `m.__file__.endswith('.so')` is just `False`, + no exception, easy to mistake for "the wheel shipped pure Python". maturin makes this + call from the checked-out file layout alone (`project_layout.rs`'s `determine()`: no + `/__init__.py` next to `Cargo.toml` and no `[tool.maturin] python-source` means + "pure Rust", and `module_dir()`'s own doc comment says outright that the module dir it + returns *is* the generated package around the extension) — before it ever knows which + interpreter it's building for, so the same shim ships identically on an abi3 leg and a + free-threaded leg of the same crate. The build log's "Found type stub file at + `.pyi`" line is a red herring here too: it means a `.pyi` rides along inside that + generated package, not that the layout is somehow different because of it. + - **Use gotcha 308's `sys.modules` fix unconditionally for any pure-Rust maturin + project**, not only after a collision bites: `python -c "import , sys; assert + sys.modules['.'].__file__.endswith('.so')"`. Cheaper still, `unzip -l` on + the wheel shows the shim/extension pair (gotcha 9/56/308's standing advice) before + writing the probe at all. + - **Don't blame the interpreter for a per-leg failure until the sibling leg has + actually run.** `build-ruff-format.yml`'s first CI run showed the failure on + `cp314t` only — but that was gotcha 402's matrix collapse (the `include:`-only + `tag`/`build` keys folded both legs into one job), not evidence the smoke test was + somehow free-threading-specific: `cp38-abi3` had not run at all (absent from the job + list, not merely queued) and failed identically once the matrix fix let it run. + Check the run's job list against the declared legs before a diagnosis that starts + "only cp314t" — gotcha 402's own advice, worth repeating here because the two bugs + compounded in one PR. + 398. **Reproducing a `py3-none-` wheel takes an explicit retag — setuptools' `bdist_wheel` ignores `--python-tag` the moment `ext_modules` is non-empty (the mediapipe case; see `build-mediapipe.yml`).** Gotchas 81/145/292 settle how to *read*