Skip to content

Commit 7f4c1b3

Browse files
authored
ci: Upload fixed python stubs as an artifact in CI (#4754)
If the python stubs test fails (because the API changed in some way that needs the stubs regenerated, but the submitter of the PR did not or could not, the wheel CI will regenerate the stubs and include them in the failure artifact. This provides a path for users who can't build the stubs locally. Signed-off-by: Chad Dombrova <chadrik@gmail.com>
1 parent 88c2d75 commit 7f4c1b3

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

.github/workflows/wheel.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,11 @@ jobs:
163163
- uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
164164
with:
165165
name: cibw-wheels-${{ matrix.python }}-${{ matrix.manylinux }}
166-
path: ./wheelhouse/*.whl
166+
path: |
167+
./wheelhouse/*.whl
168+
./wheelhouse/OpenImageIO/__init__.pyi
169+
# if stub validation fails we want to upload the stubs for users to review
170+
if: success() || failure()
167171

168172
# ---------------------------------------------------------------------------
169173
# Linux ARM Wheels
@@ -225,7 +229,11 @@ jobs:
225229
- uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
226230
with:
227231
name: cibw-wheels-${{ matrix.python }}-${{ matrix.manylinux }}
228-
path: ./wheelhouse/*.whl
232+
path: |
233+
./wheelhouse/*.whl
234+
./wheelhouse/OpenImageIO/__init__.pyi
235+
# if stub validation fails we want to upload the stubs for users to review
236+
if: success() || failure()
229237

230238
# ---------------------------------------------------------------------------
231239
# macOS Wheels

INSTALL.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ for more information on customizing and overriding build-tool options and CMake
398398
This repo contains python type stubs which are generated from `pybind11` signatures.
399399
The workflow for releasing new stubs is as follows:
400400

401-
- Install [`uv`](https://docs.astral.sh/uv/getting-started/installation/)
401+
- Install [`uv`](https://docs.astral.sh/uv/getting-started/installation/) and `docker`
402402
- Run `make pystubs` locally to generate updated stubs in `src/python/stubs/__init__.pyi`
403403
- Run `make test-pystubs` locally to use mypy to test the stubs against the code in
404404
the python testsuite.
@@ -411,6 +411,10 @@ The workflow for releasing new stubs is as follows:
411411
the stubs, so that changes can be reviewed and the rules in `generate_stubs.py`
412412
can be updated, if necessary.
413413

414+
Note that if you can't (or don't want to) build the stubs locally, you can
415+
download an artifact containing the wheel and `__init__.pyi` file from any job
416+
that fails the stub validation.
417+
414418
Test Images
415419
-----------
416420

src/python/stubs/generate_stubs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ def main() -> None:
208208
print("Changes to the source code have resulted in a change to the stubs.")
209209
print(get_colored_diff(old_text, new_text))
210210
print("Run `make pystubs` locally and commit the results for review.")
211+
print("The resulting __init__.pyi file will be uploaded as an artifact on this job.")
211212
sys.exit(2)
212213

213214

0 commit comments

Comments
 (0)