Repository navigation
Ship the py.typed marker in the Python wheel - #34010
Open
Danny On The Air (dannyota) wants to merge 1 commit into
Open
Danny On The Air (dannyota) wants to merge 1 commit into
Danny On The Air (dannyota) wants to merge 1 commit into
Conversation
microsoft#28438 added onnxruntime/py.typed and listed it in setup.py's package_data, but setup.py runs in the build tree and CMake never copied the marker there. Released wheels (1.31.1) still lack it, so mypy keeps reporting import-untyped (microsoft#32615). Copy py.typed next to __init__.py, and run the existing PEP 561 marker test with the other Python tests so the regression is caught. Signed-off-by: Danny <dannyontheair@outlook.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change to include the PEP 561 marker in Python wheels.
No open issues 🎉
What changed in this PR
Fixes the missing PEP 561 marker in Python wheels by copying py.typed into the build tree used for packaging. This completes the packaging work from #28438 and addresses the missing-marker cause of mypy’s import-untyped error reported in #32615.
Changes:
- Copy
py.typedalongside the package’s__init__.py. - Run the existing marker regression test with the Python test suite.
| File | Description |
|---|---|
tools/ci_build/build.py |
Adds the existing PEP 561 marker test to Python test execution. |
cmake/onnxruntime_python.cmake |
Copies py.typed into the build-tree package for wheel inclusion. |
Review effort: Balanced
This branch has not been deployed
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.
Description
#28438 added
onnxruntime/py.typedand listed it insetup.pypackage_data, butsetup.pyruns in the build tree and CMake never copied the marker there. Wheels still ship without it (checked the 1.31.1 wheel), so mypy reportsimport-untyped.py.typednext to__init__.pyincmake/onnxruntime_python.cmake.test_pep561_py_typed_marker.pywith the other Python tests inbuild.py. Linux wheel CI runs it against the installed wheel.Testing
--build_wheel:onnxruntime/py.typedis in the wheel, the marker test passes against the installed wheel, and mypy onimport onnxruntimereports no issues.import-untyped.Motivation and Context
Fixes the mypy error reported in #32615. Type stubs for the pybind11 module are a separate step.