Expose executorch.__version__#20271
Conversation
Re-export the build-generated version from the package root.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20271
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ❌ 11 New Failures, 1 Cancelled Job, 13 Pending, 1 Unclassified FailureAs of commit 22a82d0 with merge base 0378fc4 ( NEW FAILURES - The following jobs have failed:
UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
There was a problem hiding this comment.
Pull request overview
Adds a top-level executorch Python package initializer to expose conventional version attributes (executorch.__version__, executorch.git_version) while keeping imports resilient in unbuilt source-tree scenarios.
Changes:
- Introduces
src/executorch/__init__.pyto re-export__version__andgit_versionfrom the generatedexecutorch/version.py. - Implements a fallback to
importlib.metadata(and finally0.0.0+unknown) soimport executorchdoes not fail whenversion.pyisn’t present.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses review: only fall back when version.py is absent; a present-but-broken version.py now surfaces.
|
Thanks for the review — addressed both:
|
|
Closing this — CI shows the approach is incompatible with ExecuTorch's packaging model. Adding a top-level This is the namespace-package risk noted in the PR description, now confirmed by CI (11 jobs, deterministic). Since The underlying gap is real — the build already generates |
Summary
import executorch; executorch.__version__currently raisesAttributeError, even thoughtorch.__version__,numpy.__version__, etc. all work. The version data already exists:setup.pygeneratesexecutorch/version.py(with__version__andgit_version) fromversion.txtat build time, mirroringtorch/version.py. Butexecutorchhas no top-level__init__.pyto re-export it, so the generated module is never surfaced on the package. (executorch.version.__version__works today; the conventionalexecutorch.__version__does not.)This adds
src/executorch/__init__.pythat re-exports the generated version, with a graceful fallback soimport executorchnever fails in an unbuilt source tree:executorch/version.py(exact build version + git hash);importlib.metadata;0.0.0+unknown(never raises).version.txtstays the single source of truth; no version string is hardcoded, andsetup.pyis unchanged (it already generatesversion.pyin this directory).Note for reviewers
This promotes
executorchfrom an implicit (PEP 420) namespace package to a regular package. For the single-wheel layout this is the conventional setup and matchestorch/numpy, but please confirm no consumer relies on namespace-package merging ofexecutorch.*across multiple roots.Test plan