Skip to content

Commit 5a48a5f

Browse files
committed
fix(python): include generated proto stubs in Linux wheels
The generated protobuf/gRPC modules under python/openshell/_proto/ are gitignored. maturin honors .gitignore when collecting python-source files from a git checkout, so native builds (Linux release CI, local pip install .) dropped these modules and shipped an unimportable wheel. The macOS wheel only included them by accident: it builds in a Docker context whose COPY omits .git, so maturin had no gitignore to apply. Pin the stubs back in with explicit, package-relative [tool.maturin].include globs so inclusion no longer depends on whether .git is present in the build context. Add a wheel smoke check to the release-tag and release-dev workflows that installs each Linux wheel in a clean python:3.12-slim image and imports openshell.sandbox, and document the invariant in architecture/build.md. Closes #1705 Signed-off-by: Max Dubrinsky <mdubrinsky@nvidia.com>
1 parent d93293a commit 5a48a5f

4 files changed

Lines changed: 83 additions & 2 deletions

File tree

.github/workflows/release-dev.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ jobs:
679679

680680
smoke-linux-dev-artifacts:
681681
name: Smoke Linux Dev Artifacts (${{ matrix.name }})
682-
needs: [build-gateway-binary-linux, build-driver-vm-linux, build-deb, build-rpm]
682+
needs: [build-gateway-binary-linux, build-driver-vm-linux, build-deb, build-rpm, build-python-wheels-linux]
683683
timeout-minutes: 20
684684
strategy:
685685
fail-fast: false
@@ -709,6 +709,18 @@ jobs:
709709
kind: rpm
710710
artifact_arch: arm64
711711
rpm_arch: aarch64
712+
- name: python-wheel-amd64
713+
runner: linux-amd64-cpu8
714+
image: python:3.12-slim
715+
kind: wheel
716+
artifact_arch: amd64
717+
rpm_arch: x86_64
718+
- name: python-wheel-arm64
719+
runner: linux-arm64-cpu8
720+
image: python:3.12-slim
721+
kind: wheel
722+
artifact_arch: arm64
723+
rpm_arch: aarch64
712724
runs-on: ${{ matrix.runner }}
713725
container:
714726
image: ${{ matrix.image }}
@@ -743,6 +755,25 @@ jobs:
743755
dnf install -y ./package-input/openshell-[0-9]*.rpm ./package-input/openshell-gateway-*.rpm
744756
LD_BIND_NOW=1 openshell-gateway --version
745757
758+
- name: Download Python wheel artifact
759+
if: matrix.kind == 'wheel'
760+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
761+
with:
762+
name: python-wheels-linux-${{ matrix.artifact_arch }}
763+
path: wheel-input/
764+
765+
- name: Smoke Python wheel
766+
if: matrix.kind == 'wheel'
767+
run: |
768+
set -euo pipefail
769+
pip install --no-cache-dir wheel-input/*.whl
770+
python - <<'PY'
771+
import importlib
772+
for name in ("openshell", "openshell._proto", "openshell.sandbox"):
773+
importlib.import_module(name)
774+
print(name, "OK")
775+
PY
776+
746777
# ---------------------------------------------------------------------------
747778
# Create / update the dev GitHub Release with CLI, gateway, driver, and wheels
748779
# ---------------------------------------------------------------------------

.github/workflows/release-tag.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ jobs:
715715

716716
smoke-linux-release-artifacts:
717717
name: Smoke Linux Release Artifacts (${{ matrix.name }})
718-
needs: [build-gateway-binary-linux, build-driver-vm-linux, build-deb, build-rpm]
718+
needs: [build-gateway-binary-linux, build-driver-vm-linux, build-deb, build-rpm, build-python-wheels-linux]
719719
timeout-minutes: 20
720720
strategy:
721721
fail-fast: false
@@ -763,6 +763,20 @@ jobs:
763763
artifact_arch: arm64
764764
rpm_arch: aarch64
765765
target: aarch64-unknown-linux-gnu
766+
- name: python-wheel
767+
runner: linux-amd64-cpu8
768+
image: python:3.12-slim
769+
kind: wheel
770+
artifact_arch: amd64
771+
rpm_arch: x86_64
772+
target: x86_64-unknown-linux-gnu
773+
- name: python-wheel-arm64
774+
runner: linux-arm64-cpu8
775+
image: python:3.12-slim
776+
kind: wheel
777+
artifact_arch: arm64
778+
rpm_arch: aarch64
779+
target: aarch64-unknown-linux-gnu
766780
runs-on: ${{ matrix.runner }}
767781
container:
768782
image: ${{ matrix.image }}
@@ -822,6 +836,25 @@ jobs:
822836
dnf install -y ./package-input/openshell-[0-9]*.rpm ./package-input/openshell-gateway-*.rpm
823837
LD_BIND_NOW=1 openshell-gateway --version
824838
839+
- name: Download Python wheel artifact
840+
if: matrix.kind == 'wheel'
841+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
842+
with:
843+
name: python-wheels-linux-${{ matrix.artifact_arch }}
844+
path: wheel-input/
845+
846+
- name: Smoke Python wheel
847+
if: matrix.kind == 'wheel'
848+
run: |
849+
set -euo pipefail
850+
pip install --no-cache-dir wheel-input/*.whl
851+
python - <<'PY'
852+
import importlib
853+
for name in ("openshell", "openshell._proto", "openshell.sandbox"):
854+
importlib.import_module(name)
855+
print(name, "OK")
856+
PY
857+
825858
# ---------------------------------------------------------------------------
826859
# Create a tagged GitHub Release with CLI, gateway, driver, and wheels
827860
# ---------------------------------------------------------------------------

architecture/build.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,16 @@ contexts use `KIND_EXPERIMENTAL_PROVIDER=docker|podman` when set, and ambiguous
126126
or unknown contexts require an explicit `CONTAINER_ENGINE`. Other image builds
127127
do not infer from kube context.
128128

129+
## Python Wheel Packaging
130+
131+
The generated protobuf/gRPC stubs under `python/openshell/_proto/` are gitignored
132+
build outputs of `mise run python:proto`. maturin honors `.gitignore` when
133+
collecting `python-source` files, so native builds (Linux CI, local
134+
`pip install .`) would drop them and ship an unimportable wheel. `pyproject.toml`
135+
pins them back in with `[tool.maturin].include` globs. The release workflows
136+
install each Linux wheel in a clean image and import `openshell.sandbox` as a
137+
smoke check.
138+
129139
## CI and E2E
130140

131141
Required checks run on GitHub Actions. Workflows that use NVIDIA self-hosted runners trigger from copy-pr-bot mirror branches, so trusted PRs are mirrored into `pull-request/<N>` branches before those workflows run.

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ bindings = "bin"
7070
manifest-path = "crates/openshell-cli/Cargo.toml"
7171
python-source = "python"
7272
module-name = "openshell"
73+
# _proto/ stubs are gitignored; force them into the wheel so git-aware
74+
# maturin builds don't drop them (package-relative paths).
75+
include = [
76+
"openshell/_proto/*_pb2.py",
77+
"openshell/_proto/*_pb2_grpc.py",
78+
"openshell/_proto/*.pyi",
79+
]
7380

7481
[tool.ruff]
7582
target-version = "py312"

0 commit comments

Comments
 (0)