Skip to content

Commit 3ce0d9a

Browse files
committed
ci(python): replace custom Dockerfile with PyO3/maturin-action for Linux wheels
1 parent cc68036 commit 3ce0d9a

5 files changed

Lines changed: 47 additions & 263 deletions

File tree

.github/workflows/release-dev.yml

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -105,59 +105,44 @@ jobs:
105105
- arch: amd64
106106
runner: build-amd64
107107
artifact: linux-amd64
108-
task: python:build:linux:amd64
109-
output_path: target/wheels/linux-amd64/*.whl
108+
target: x86_64-unknown-linux-gnu
110109
- arch: arm64
111110
runner: build-arm64
112111
artifact: linux-arm64
113-
task: python:build:linux:arm64
114-
output_path: target/wheels/linux-arm64/*.whl
112+
target: aarch64-unknown-linux-gnu
115113
runs-on: ${{ matrix.runner }}
116114
timeout-minutes: 120
117-
container:
118-
image: ghcr.io/nvidia/openshell/ci:latest
119-
credentials:
120-
username: ${{ github.actor }}
121-
password: ${{ secrets.GITHUB_TOKEN }}
122-
options: --privileged
123-
volumes:
124-
- /var/run/docker.sock:/var/run/docker.sock
125-
env:
126-
MISE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127-
SCCACHE_MEMCACHED_ENDPOINT: ${{ vars.SCCACHE_MEMCACHED_ENDPOINT }}
128-
OPENSHELL_IMAGE_TAG: dev
129115
steps:
130116
- uses: actions/checkout@v4
131117
with:
132118
fetch-depth: 0
133119

134-
- name: Set up Docker Buildx
135-
uses: ./.github/actions/setup-buildx
120+
- name: Set up mise
121+
uses: jdx/mise-action@v2
136122

137-
- name: Mark workspace safe for git
138-
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
123+
- name: Generate Python protobuf stubs
124+
run: uv sync --group dev && mise run python:proto
139125

140-
- name: Sync Python dependencies
141-
run: uv sync
126+
- name: Patch workspace version
127+
if: needs.compute-versions.outputs.cargo_version != ''
128+
run: |
129+
sed -i -E '/^\[workspace\.package\]/,/^\[/{s/^version[[:space:]]*=[[:space:]]*".*"/version = "${{ needs.compute-versions.outputs.cargo_version }}"/}' Cargo.toml
142130
143-
- name: Cache Rust target and registry
144-
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
131+
- name: Build Python wheel
132+
uses: PyO3/maturin-action@v1
145133
with:
146-
shared-key: python-wheel-linux-${{ matrix.arch }}
147-
cache-directories: .cache/sccache
148-
cache-targets: "true"
149-
150-
- name: Build Python wheels
151-
run: |
152-
set -euo pipefail
153-
OPENSHELL_CARGO_VERSION="${{ needs.compute-versions.outputs.cargo_version }}" mise run ${{ matrix.task }}
154-
ls -la ${{ matrix.output_path }}
134+
target: ${{ matrix.target }}
135+
manylinux: 2_28
136+
args: --release --features bundled-z3 --compatibility manylinux_2_28 --out dist
137+
before-script-linux: |
138+
dnf install -y --setopt=install_weak_deps=False \
139+
clang llvm-devel openssl-devel perl-core perl-IPC-Cmd
155140
156141
- name: Upload wheel artifacts
157142
uses: actions/upload-artifact@v4
158143
with:
159144
name: python-wheels-${{ matrix.artifact }}
160-
path: ${{ matrix.output_path }}
145+
path: dist/*.whl
161146
retention-days: 5
162147

163148
build-python-wheel-macos:

.github/workflows/release-tag.yml

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -125,60 +125,45 @@ jobs:
125125
- arch: amd64
126126
runner: build-amd64
127127
artifact: linux-amd64
128-
task: python:build:linux:amd64
129-
output_path: target/wheels/linux-amd64/*.whl
128+
target: x86_64-unknown-linux-gnu
130129
- arch: arm64
131130
runner: build-arm64
132131
artifact: linux-arm64
133-
task: python:build:linux:arm64
134-
output_path: target/wheels/linux-arm64/*.whl
132+
target: aarch64-unknown-linux-gnu
135133
runs-on: ${{ matrix.runner }}
136134
timeout-minutes: 120
137-
container:
138-
image: ghcr.io/nvidia/openshell/ci:latest
139-
credentials:
140-
username: ${{ github.actor }}
141-
password: ${{ secrets.GITHUB_TOKEN }}
142-
options: --privileged
143-
volumes:
144-
- /var/run/docker.sock:/var/run/docker.sock
145-
env:
146-
MISE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
147-
SCCACHE_MEMCACHED_ENDPOINT: ${{ vars.SCCACHE_MEMCACHED_ENDPOINT }}
148-
OPENSHELL_IMAGE_TAG: ${{ needs.compute-versions.outputs.semver }}
149135
steps:
150136
- uses: actions/checkout@v4
151137
with:
152138
ref: ${{ inputs.tag || github.ref }}
153139
fetch-depth: 0
154140

155-
- name: Set up Docker Buildx
156-
uses: ./.github/actions/setup-buildx
141+
- name: Set up mise
142+
uses: jdx/mise-action@v2
157143

158-
- name: Mark workspace safe for git
159-
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
144+
- name: Generate Python protobuf stubs
145+
run: uv sync --group dev && mise run python:proto
160146

161-
- name: Sync Python dependencies
162-
run: uv sync
147+
- name: Patch workspace version
148+
if: needs.compute-versions.outputs.cargo_version != ''
149+
run: |
150+
sed -i -E '/^\[workspace\.package\]/,/^\[/{s/^version[[:space:]]*=[[:space:]]*".*"/version = "${{ needs.compute-versions.outputs.cargo_version }}"/}' Cargo.toml
163151
164-
- name: Cache Rust target and registry
165-
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2
152+
- name: Build Python wheel
153+
uses: PyO3/maturin-action@v1
166154
with:
167-
shared-key: python-wheel-linux-${{ matrix.arch }}
168-
cache-directories: .cache/sccache
169-
cache-targets: "true"
170-
171-
- name: Build Python wheels
172-
run: |
173-
set -euo pipefail
174-
OPENSHELL_CARGO_VERSION="${{ needs.compute-versions.outputs.cargo_version }}" mise run ${{ matrix.task }}
175-
ls -la ${{ matrix.output_path }}
155+
target: ${{ matrix.target }}
156+
manylinux: 2_28
157+
args: --release --features bundled-z3 --compatibility manylinux_2_28 --out dist
158+
before-script-linux: |
159+
dnf install -y --setopt=install_weak_deps=False \
160+
clang llvm-devel openssl-devel perl-core perl-IPC-Cmd
176161
177162
- name: Upload wheel artifacts
178163
uses: actions/upload-artifact@v4
179164
with:
180165
name: python-wheels-${{ matrix.artifact }}
181-
path: ${{ matrix.output_path }}
166+
path: dist/*.whl
182167
retention-days: 5
183168

184169
build-python-wheel-macos:

architecture/build-containers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ Both the standalone artifact and the deployed container image use the `openshell
4343

4444
OpenShell also publishes Python wheels for `linux/amd64`, `linux/arm64`, and macOS ARM64.
4545

46-
- Released Linux wheels are built per-arch inside `deploy/docker/Dockerfile.python-wheels-linux`, which uses the PyPA `manylinux_2_28_{x86_64,aarch64}` images as a base. The resulting wheels are tagged `manylinux_2_28` and install on any Linux distribution shipping glibc >= 2.28 (RHEL 8, Debian 10+, Ubuntu 18.04+). The matrix job invokes `mise run python:build:linux:amd64` / `python:build:linux:arm64`, which fan out to `build:python:wheel:linux:{amd64,arm64}:docker`.
47-
- For fast local iteration, `build:python:wheel:linux:amd64` / `build:python:wheel:linux:arm64` still produce a non-portable wheel tagged for the host's glibc. These tasks are no longer used by release workflows.
46+
- Released Linux wheels are built per-arch using `PyO3/maturin-action` with `manylinux: 2_28`. The action pulls the PyPA `manylinux_2_28` container, installs Rust from `rust-toolchain.toml`, and runs `maturin build --features bundled-z3 --compatibility manylinux_2_28`. The resulting wheels install on any Linux with glibc >= 2.28 (RHEL 8+, Ubuntu 18.04+, Debian 10+). This follows the same pattern used by ruff and uv.
47+
- For fast local iteration, `build:python:wheel:linux:{amd64,arm64}` build natively on the host (wheels tagged for the host glibc, not portable).
4848
- The macOS ARM64 wheel is cross-compiled with `deploy/docker/Dockerfile.python-wheels-macos` via `build:python:wheel:macos`.
4949
- Release workflows mirror the CLI layout: a Linux matrix job for amd64/arm64, a separate macOS job, and release jobs that download the per-platform wheel artifacts directly before publishing.
5050

deploy/docker/Dockerfile.python-wheels-linux

Lines changed: 0 additions & 119 deletions
This file was deleted.

tasks/python.toml

Lines changed: 7 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -92,84 +92,17 @@ description = "Build Python wheel for Linux arm64 natively (host glibc; non-port
9292
depends = ["EXPECTED_HOST_ARCH=arm64 WHEEL_OUTPUT_DIR=target/wheels/linux-arm64 build:python:wheel:linux"]
9393
hide = true
9494

95-
["build:python:wheel:linux:docker"]
96-
description = "Build a portable manylinux_2_28 Python wheel via Docker (glibc >= 2.28)"
97-
depends = ["python:proto"]
98-
run = """
99-
#!/usr/bin/env bash
100-
set -euo pipefail
101-
102-
source tasks/scripts/container-engine.sh
103-
104-
WHEEL_OUTPUT_DIR=${WHEEL_OUTPUT_DIR:?Set WHEEL_OUTPUT_DIR to a per-platform wheel output directory}
105-
TARGETARCH=${TARGETARCH:?Set TARGETARCH to amd64 or arm64}
106-
107-
sha256_16() {
108-
if command -v sha256sum >/dev/null 2>&1; then
109-
sha256sum "$1" | awk '{print substr($1, 1, 16)}'
110-
else
111-
shasum -a 256 "$1" | awk '{print substr($1, 1, 16)}'
112-
fi
113-
}
114-
115-
sha256_16_stdin() {
116-
if command -v sha256sum >/dev/null 2>&1; then
117-
sha256sum | awk '{print substr($1, 1, 16)}'
118-
else
119-
shasum -a 256 | awk '{print substr($1, 1, 16)}'
120-
fi
121-
}
122-
123-
CARGO_VERSION=${OPENSHELL_CARGO_VERSION:-}
124-
if [ -z "$CARGO_VERSION" ] && [ -n "${CI:-}" ]; then
125-
CARGO_VERSION=$(uv run python tasks/scripts/release.py get-version --cargo)
126-
fi
127-
128-
LOCK_HASH=$(sha256_16 Cargo.lock)
129-
RUST_SCOPE=${RUST_TOOLCHAIN_SCOPE:-rustup-1.95.0}
130-
CACHE_SCOPE_INPUT="v1|python-wheels-linux-${TARGETARCH}|manylinux_2_28|${LOCK_HASH}|${RUST_SCOPE}"
131-
CARGO_TARGET_CACHE_SCOPE=$(printf '%s' "$CACHE_SCOPE_INPUT" | sha256_16_stdin)
132-
133-
rm -rf "$WHEEL_OUTPUT_DIR"
134-
mkdir -p "$WHEEL_OUTPUT_DIR"
135-
136-
ce build \
137-
-f deploy/docker/Dockerfile.python-wheels-linux \
138-
--target wheels \
139-
--build-arg "TARGETARCH=${TARGETARCH}" \
140-
--build-arg "CARGO_TARGET_CACHE_SCOPE=${CARGO_TARGET_CACHE_SCOPE}" \
141-
${CARGO_VERSION:+--build-arg "OPENSHELL_CARGO_VERSION=${CARGO_VERSION}"} \
142-
${OPENSHELL_IMAGE_TAG:+--build-arg "OPENSHELL_IMAGE_TAG=${OPENSHELL_IMAGE_TAG}"} \
143-
--output "type=local,dest=${WHEEL_OUTPUT_DIR}" \
144-
.
145-
146-
ls -la "$WHEEL_OUTPUT_DIR"/*.whl
147-
"""
148-
hide = true
149-
150-
["build:python:wheel:linux:amd64:docker"]
151-
description = "Build portable manylinux_2_28 wheel for Linux amd64"
152-
depends = ["TARGETARCH=amd64 WHEEL_OUTPUT_DIR=target/wheels/linux-amd64 build:python:wheel:linux:docker"]
153-
hide = true
154-
155-
["build:python:wheel:linux:arm64:docker"]
156-
description = "Build portable manylinux_2_28 wheel for Linux arm64"
157-
depends = ["TARGETARCH=arm64 WHEEL_OUTPUT_DIR=target/wheels/linux-arm64 build:python:wheel:linux:docker"]
158-
hide = true
159-
160-
# Release-pipeline aliases. These produce manylinux_2_28-tagged wheels via
161-
# Docker so the published artifacts install on any glibc >= 2.28 host (RHEL 8,
162-
# Ubuntu 18.04+, Debian 10+). The native `build:python:wheel:linux:amd64` /
163-
# `build:python:wheel:linux:arm64` tasks remain available for fast local
164-
# iteration and produce wheels tagged for the host glibc only.
95+
# Release-pipeline aliases. CI uses PyO3/maturin-action directly (see
96+
# .github/workflows/release-*.yml); these aliases remain for local iteration
97+
# and produce wheels tagged for the host glibc only.
16598
["python:build:linux:amd64"]
166-
description = "Build portable manylinux_2_28 wheel for Linux amd64 (release path)"
167-
depends = ["build:python:wheel:linux:amd64:docker"]
99+
description = "Build Python wheel for Linux amd64 (local dev; CI uses maturin-action)"
100+
depends = ["build:python:wheel:linux:amd64"]
168101
hide = true
169102

170103
["python:build:linux:arm64"]
171-
description = "Build portable manylinux_2_28 wheel for Linux arm64 (release path)"
172-
depends = ["build:python:wheel:linux:arm64:docker"]
104+
description = "Build Python wheel for Linux arm64 (local dev; CI uses maturin-action)"
105+
depends = ["build:python:wheel:linux:arm64"]
173106
hide = true
174107

175108
["build:python:wheel:macos"]

0 commit comments

Comments
 (0)