Skip to content

Commit 0eb5fbf

Browse files
committed
ruff-format: PR #2198 fully green, add gotcha 559 (pure-Rust maturin __file__ shim)
Replicates PR #2264's bookkeeping directly to main (renumbered 558->559 to avoid colliding with ifcopenshell's concurrently-landed 558) since that PR's own agent hit a permission wall pushing to main directly.
1 parent 34949cf commit 0eb5fbf

3 files changed

Lines changed: 36 additions & 2 deletions

File tree

‎.queue.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8427,9 +8427,9 @@ packages:
84278427
version: 0.5.4
84288428
home: https://github.com/reflex-dev/ruff-format
84298429
repo: https://github.com/reflex-dev/ruff-format
8430-
status: ci-running
8430+
status: ci-green
84318431
pr: https://github.com/riseproject-dev/python-wheels/pull/2198
8432-
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.'
8432+
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 559 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.'
84338433
- pkg: arro3-io
84348434
version: 0.8.2
84358435
home: https://kylebarron.dev/arro3

‎skills/python-project-porting/references/gotchas-index.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,7 @@ The porting gotchas (546 of them) live in [`references/gotchas/`](gotchas/), spl
917917
- **292** — Gotcha 81's "diff the wheel `size` field" test can pass on a real per-arch binary
918918
- **295** — A require-extension knob that reaches the container correctly (gotcha 129's
919919
- **308** — A maturin shim whose star-import name collides with the compiled submodule's
920+
- **559** — A pure-Rust maturin project's top-level `__file__` never points at the `.so` —
920921
- **398** — Reproducing a `py3-none-<platform>` wheel takes an explicit retag — setuptools'
921922
- **457** — On cp314t our registry can hand a package a *compiled* dependency wheel where
922923
- **510** — A cffi *ABI-mode* payload keeps its `py3-none` tag through `auditwheel repair` —

‎skills/python-project-porting/references/gotchas/compiled-vs-pure-detection.md‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ To pull up one entry: `grep -n '^N\. ' references/gotchas/compiled-vs-pure-detec
2020
- **292** — Gotcha 81's "diff the wheel `size` field" test can pass on a real per-arch binary
2121
- **295** — A require-extension knob that reaches the container correctly (gotcha 129's
2222
- **308** — A maturin shim whose star-import name collides with the compiled submodule's
23+
- **559** — A pure-Rust maturin project's top-level `__file__` never points at the `.so` —
2324
- **398** — Reproducing a `py3-none-<platform>` wheel takes an explicit retag — setuptools'
2425
- **457** — On cp314t our registry can hand a package a *compiled* dependency wheel where
2526
- **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
395396
`murmurhash2/murmurhash2.abi3.so` next to each other names both the shim and the
396397
real extension before a single CI cycle is spent on the wrong probe.
397398

399+
559. **A pure-Rust maturin project's top-level `__file__` never points at the `.so` — not
400+
just when a name collides with gotcha 308's shim (the ruff-format case; see
401+
`build-ruff-format.yml`).** Gotcha 308 covers a *collision*: the generated
402+
`__init__.py`'s `from .<mod> import *` overwriting the submodule attribute with a
403+
same-named exported function, which raises `AttributeError` on `.__file__`. A pure-Rust
404+
maturin crate with no such collision fails the same probe more quietly: `import
405+
ruff_format as m; m.__file__` resolves fine, but to the generated
406+
`ruff_format/__init__.py` (a `.py` file) — `m.__file__.endswith('.so')` is just `False`,
407+
no exception, easy to mistake for "the wheel shipped pure Python". maturin makes this
408+
call from the checked-out file layout alone (`project_layout.rs`'s `determine()`: no
409+
`<module>/__init__.py` next to `Cargo.toml` and no `[tool.maturin] python-source` means
410+
"pure Rust", and `module_dir()`'s own doc comment says outright that the module dir it
411+
returns *is* the generated package around the extension) — before it ever knows which
412+
interpreter it's building for, so the same shim ships identically on an abi3 leg and a
413+
free-threaded leg of the same crate. The build log's "Found type stub file at
414+
`<mod>.pyi`" line is a red herring here too: it means a `.pyi` rides along inside that
415+
generated package, not that the layout is somehow different because of it.
416+
- **Use gotcha 308's `sys.modules` fix unconditionally for any pure-Rust maturin
417+
project**, not only after a collision bites: `python -c "import <mod>, sys; assert
418+
sys.modules['<mod>.<mod>'].__file__.endswith('.so')"`. Cheaper still, `unzip -l` on
419+
the wheel shows the shim/extension pair (gotcha 9/56/308's standing advice) before
420+
writing the probe at all.
421+
- **Don't blame the interpreter for a per-leg failure until the sibling leg has
422+
actually run.** `build-ruff-format.yml`'s first CI run showed the failure on
423+
`cp314t` only — but that was gotcha 402's matrix collapse (the `include:`-only
424+
`tag`/`build` keys folded both legs into one job), not evidence the smoke test was
425+
somehow free-threading-specific: `cp38-abi3` had not run at all (absent from the job
426+
list, not merely queued) and failed identically once the matrix fix let it run.
427+
Check the run's job list against the declared legs before a diagnosis that starts
428+
"only cp314t" — gotcha 402's own advice, worth repeating here because the two bugs
429+
compounded in one PR.
430+
398431
398. **Reproducing a `py3-none-<platform>` wheel takes an explicit retag — setuptools'
399432
`bdist_wheel` ignores `--python-tag` the moment `ext_modules` is non-empty (the
400433
mediapipe case; see `build-mediapipe.yml`).** Gotchas 81/145/292 settle how to *read*

0 commit comments

Comments
 (0)