Add pip wrapper for clickhousectl via maturin#216
Open
sdairs wants to merge 1 commit into
Open
Conversation
Publishes per-platform Python wheels containing the prebuilt `clickhousectl` binary so users can install via `pip install clickhousectl` (or pipx / uv tool). Mirrors the existing npm wrapper. Approach follows zizmor's pattern: a `pypi/pyproject.toml` configured with `bindings = "bin"` pointing at the existing `crates/clickhousectl` manifest. Maturin compiles the binary and packages it as the wheel's script, so no Python shim is needed. The wheel version is pulled dynamically from `Cargo.toml`, so there's no separate version to maintain in lockstep. Release workflow adds two jobs after `publish-npm`: - `build-wheels`: matrix over manylinux x86_64/aarch64, musllinux x86_64/aarch64, and macOS x86_64/arm64 (6 wheels) - `publish-pypi`: uploads via `pypa/gh-action-pypi-publish` using OIDC trusted publishing (no API token secret) Both action SHAs are pinned. The trusted-publisher relationship needs a one-time setup on pypi.org before the first tagged release. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
pypi/pyproject.toml(maturin,bindings = "bin") so the existingcrates/clickhousectlbinary can be published as a per-platform Python wheel — mirrors the existing npm wrapper, but using the zizmor / ruff / uv pattern instead of a postinstall downloader (pip doesn't have a clean postinstall hook)..github/workflows/release.ymlwith two jobs afterpublish-npm:build-wheels: matrix builds 6 wheels (manylinux x86_64+aarch64, musllinux x86_64+aarch64, macOS x86_64+arm64) viaPyO3/maturin-action@v1.51.0(SHA-pinned).publish-pypi: uploads viapypa/gh-action-pypi-publish@v1.14.0(SHA-pinned) using OIDC trusted publishing — no API token secret needed.README.mdwith a### pipinstall section next to the npm one.CLAUDE.mdto note: wheel version is dynamic fromCargo.toml(no extra lockstep bump), and PyPI trusted-publisher setup is a one-time pypi.org config.The wheel version is pulled from
crates/clickhousectl/Cargo.tomlviadynamic = ["version"], and the build job also re-aligns the Cargo version to the tag at publish time (mirroring the existing npm step) — so a single source of truth.One-time setup needed before first release
Register a trusted publisher on pypi.org for the
clickhousectlproject:ClickHouseclickhousectlrelease.ymlUntil that's configured, the
publish-pypijob will fail at the OIDC handshake. The rest of the release (binaries, npm, crates.io) is unaffected.Test plan
maturin build --releaseinpypi/producesclickhousectl-0.2.3-py3-none-macosx_11_0_arm64.whl(5.4 MB, version pulled from Cargo.toml automatically).pip installthe resulting wheel;clickhousectl --versionprintsclickhousectl 0.2.3;clickhousectl local --helpshows the full subcommand surface.release.ymlparses as valid YAML.v0.2.4-rc1) once trusted publishing is configured, verify the 6 wheels build and publish, thenpip install clickhousectl==0.2.4rc1works in a fresh venv on macOS arm64 + a Linux container.Out of scope
chctlshort alias for pip — npm-only for v1 (would need a second cargo bin target or a Python shim).🤖 Generated with Claude Code