Skip to content

Restore type stubs in frontend wheels - #3928

Closed
jasp-nerd wants to merge 1 commit into
ml-explore:mainfrom
jasp-nerd:codex/fix-wheel-stubs-3916
Closed

jasp-nerd wants to merge 1 commit into
ml-explore:mainfrom
jasp-nerd:codex/fix-wheel-stubs-3916

Conversation

@jasp-nerd

Copy link
Copy Markdown
Contributor

Proposed changes

Fixes #3916.

Clean frontend wheel builds run build_py before the CMake install-time stub
generator, so the generated .pyi files are too late to enter the wheel. The
previous release workflow masked this ordering problem by performing an
editable install first.

This change:

  • makes the temporary CMake install prefix absolute and exposes its shared
    library while stubgen imports the newly built extension;
  • clears old generated outputs, requires the exact eight expected stubs, and
    copies the fresh files into the wheel staging tree;
  • skips stub generation for backend-only stage-2 wheels; and
  • verifies the exact stub set in every frontend wheel build.

Validation:

clean baseline wheel: py.typed present, 0 .pyi files
clean patched wheel:  py.typed present, 8 .pyi files
forced stubgen-off build with stale outputs: fails with all 8 stubs missing
patched CPU smoke test: mx.sum([1, 2, 3]) == 6
pre-commit run --all-files: passed

The clean local wheel build used CMAKE_ARGS=-DMLX_BUILD_METAL=OFF because the
machine does not have the full Xcode Metal compiler. The packaging and stub
generation path completed; the release matrix will cover the normal Metal,
Linux, Windows, and CUDA configurations.

I used an AI coding assistant to help research and prepare this change; I
remain responsible for the submitted patch.

Checklist

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (not needed for this packaging-only change)

@zcbenz

zcbenz commented Aug 4, 2026

Copy link
Copy Markdown
Member

Thanks for looking into the issue, I happened to be refactoring the wheel building script and I included a fix in #3818.

@zcbenz zcbenz closed this Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] 0.32.0 wheels ship py.typed but no .pyi stubs — breaks type checking of mlx.core downstream

2 participants