Conversation
Member
Author
|
This pull request is part of a Mergify stack:
|
This was referenced Apr 30, 2026
There was a problem hiding this comment.
Pull request overview
This PR changes the packaging/build pipeline to produce a maturin-built wheel that includes both the existing mergify_cli/ Python package and a Rust mergify binary, with the Rust binary delegating to python -m mergify_cli for unported subcommands.
Changes:
- Switches the Python build backend from hatchling/hatch-vcs to maturin (
bindings = "bin") to ship a Rust binary inside the wheel alongside Python sources. - Refactors
mergify-py-shimto stop embedding/extracting Python sources and instead locate a sibling venv Python interpreter (or useMERGIFY_PYTHON_EXE). - Removes shim dependencies used for extraction/caching and updates the lockfile accordingly.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pyproject.toml | Replaces hatchling with maturin configuration for a binary-in-wheel distribution. |
| crates/mergify-py-shim/src/lib.rs | Simplifies shim logic to locate and exec a venv Python interpreter; updates errors/tests. |
| crates/mergify-py-shim/Cargo.toml | Drops extraction-related dependencies; adds temp-env for tests. |
| Cargo.lock | Removes now-unused crates from the dependency graph. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🔴 👀 Review RequirementsWaiting for:
This rule is failing.
🔴 🔎 ReviewsWaiting for:
This rule is failing.
🟢 🤖 Continuous IntegrationWonderful, this rule succeeded.
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 📕 PR descriptionWonderful, this rule succeeded.
|
0d9b6f9 to
e5530f7
Compare
Member
Author
Revision history
|
e5530f7 to
31628c9
Compare
31628c9 to
b6420ce
Compare
b6420ce to
f4c7454
Compare
…ngside 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: I8f6aa397e8736aa9313c033e19e5244c34038512
f4c7454 to
d7dfb31
Compare
kozlek
approved these changes
Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces hatchling with maturin so the Python wheel ships both the
existing
mergify_cli/package and the new Rust binary as abindings = "bin"console-script. The two installs side-by-side inthe same venv layout pip already produces:
The shim no longer has to embed the Python source or bootstrap a
Python interpreter — pip already installed both alongside the
binary.
mergify-py-shimshrinks from ~250 lines (include_dir +atomic file-locked extraction + cache management) to ~130 lines:
locate the sibling
python3, execpython3 -m mergify_cli, returnthe exit code. Drops
dirs,fs2,include_dirdeps.A new
MERGIFY_PYTHON_EXEenv var letscargo builddeveloperspoint at any Python interpreter that has the package on
sys.path;the no-sibling-python failure mode now produces a targeted
PythonNotFoundwith 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:
bindings = "bin").The release workflow must build a per-platform matrix; the
existing
uv buildsingle-platform path will need an updatebefore the next PyPI publish (separate PR).
dynamic = ["version"]flows fromcrates/mergify-cli/Cargo.toml's[package] versioninstead ofhatch-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 --releaseproducestarget/wheels/mergify_cli-*-macosx_*.whl. Installing into a freshuv venvlandsmergifyat<venv>/bin/mergify(Mach-O arm64) andthe Python source under
site-packages/mergify_cli/. Bothmergify --help(shimmed → Python click help) andmergify config validate(native → Rust impl) work.