Commit b6420ce
committed
build(packaging): switch wheel build to maturin, ship Rust binary alongside Python source
Replaces hatchling with maturin so the Python wheel ships *both* the
existing `mergify_cli/` package and the new Rust binary as a
`bindings = "bin"` console-script. The two installs side-by-side in
the same venv layout pip already produces:
<venv>/bin/mergify # Rust binary (this commit's
# entry point)
<venv>/bin/python3 # interpreter pip set up
<venv>/lib/.../site-packages/ # Python source + deps
The shim no longer has to embed the Python source or bootstrap a
Python interpreter — pip already installed both alongside the
binary. `mergify-py-shim` shrinks from ~250 lines (include_dir +
atomic file-locked extraction + cache management) to ~130 lines:
locate the sibling `python3`, exec `python3 -m mergify_cli`, return
the exit code. Drops `dirs`, `fs2`, `include_dir` deps.
A new `MERGIFY_PYTHON_EXE` env var lets `cargo build` developers
point at any Python interpreter that has the package on `sys.path`;
the no-sibling-python failure mode now produces a targeted
`PythonNotFound` with the exact path it tried.
This unlocks the "delete the Python copy when porting to Rust" rule:
each future port PR removes its Python implementation in the same
change, so there's never two parallel copies of the same command.
Drift goes from "watch for it" to "structurally impossible" — no
compat-test snapshot maintenance, no flag-by-flag mirroring.
Phase 6 (curl-installable static binary, no Python at all) drops
this crate entirely.
Trade-offs:
- Wheels are now platform-tagged (per maturin `bindings = "bin"`).
The release workflow must build a per-platform matrix; the
existing `uv build` single-platform path will need an update
before the next PyPI publish (separate PR).
- Version handling: `dynamic = ["version"]` flows from
`crates/mergify-cli/Cargo.toml`'s `[package] version` instead of
hatch-vcs reading git tags. Release tooling must bump the Cargo
version to match the tag (also addressed in the release-workflow
follow-up).
Verified locally: `uvx maturin build --release` produces
`target/wheels/mergify_cli-*-macosx_*.whl`. Installing into a fresh
`uv venv` lands `mergify` at `<venv>/bin/mergify` (Mach-O arm64) and
the Python source under `site-packages/mergify_cli/`. Both
`mergify --help` (shimmed → Python click help) and `mergify config
validate` (native → Rust impl) work.
Change-Id: I8f6aa397e8736aa9313c033e19e5244c340385121 parent f6a87c8 commit b6420ce
7 files changed
Lines changed: 275 additions & 359 deletions
File tree
- .github/workflows
- crates/mergify-py-shim
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
20 | 28 | | |
21 | 29 | | |
22 | 30 | | |
| |||
35 | 43 | | |
36 | 44 | | |
37 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
38 | 52 | | |
39 | 53 | | |
40 | 54 | | |
| |||
71 | 85 | | |
72 | 86 | | |
73 | 87 | | |
74 | | - | |
| 88 | + | |
75 | 89 | | |
76 | 90 | | |
77 | 91 | | |
| |||
83 | 97 | | |
84 | 98 | | |
85 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
86 | 111 | | |
87 | 112 | | |
88 | 113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
2 | 13 | | |
3 | 14 | | |
4 | 15 | | |
5 | 16 | | |
6 | 17 | | |
7 | 18 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
15 | 36 | | |
16 | 37 | | |
17 | 38 | | |
| |||
22 | 43 | | |
23 | 44 | | |
24 | 45 | | |
25 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
26 | 115 | | |
27 | | - | |
28 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
29 | 119 | | |
30 | | - | |
31 | | - | |
| 120 | + | |
| 121 | + | |
32 | 122 | | |
33 | 123 | | |
34 | 124 | | |
| 125 | + | |
| 126 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | 13 | | |
17 | 14 | | |
18 | 15 | | |
19 | | - | |
| 16 | + | |
20 | 17 | | |
21 | 18 | | |
22 | 19 | | |
0 commit comments