Repository navigation
feat(packaging): support Python toolchain make variables in py_wheel - #4257
Merged
rickeylev merged 3 commits intoOct 13, 2026
Merged
Conversation
Setting version-specific wheel tags (`python_tag`, `abi`, `platform`) and `python_requires` metadata in `py_wheel` previously required custom `select()` expressions or `TemplateVariableInfo` rules. Additionally, `platform` and `python_requires` did not expand make variables. Populate `TemplateVariableInfo` on `py_runtime_pair` with Python version, implementation, and wheel tag variables (such as `PY_WHEEL_PYTHON_TAG`, `PY_WHEEL_ABI_TAG`, and `PY_MAJOR_DOT_MINOR`), and forward them through `current_py_toolchain`. Attach the target Python toolchain to `py_wheel` so these variables are available by default, and expand make variables in `platform` and `python_requires`.
In Bazel 7 and WORKSPACE builds, `py_runtime_pair` may receive a legacy `BuiltinPyRuntimeInfo` provider, which does not define `abi_flags`, `implementation_name`, or `interpreter_version_info`. Check `hasattr(py3_runtime, "abi_flags")` before reading those fields when populating `TemplateVariableInfo`.
aignas
approved these changes
Oct 13, 2026
Python 2 is no longer supported by `py_runtime_pair`, so `py3_runtime` is always used. Remove the `py2_runtime` branch and make `py3_runtime` handling non-conditional in `_get_template_vars`.
Collaborator
Author
|
Ah, I'm recalling a conversation where we talked about moving the filename generation to use the heuristics that auditwheel (or repairwheel?) uses to determine the platform (by inspecting the .so file symbols etc). I think ultimately we should have that as the default behavior, with values like "auto" to trigger that. but for now, this is a step forward. A coworker also mentioned that rules_ml_toolchain does provide the manywheel compliance level as a setting somewhere, so maybe there is a way to plumb that up into py_wheel via, idk, the cc toolchain or something and into a makevar. |
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 13, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 13, 2026
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.
Setting version-specific wheel tags (
python_tag,abi,platform)and
python_requiresmetadata inpy_wheelpreviously required customselect()expressions orTemplateVariableInforules. Additionally,platformandpython_requiresdid not expand make variables.Populate
TemplateVariableInfoonpy_runtime_pairwith Pythonversion, implementation, and wheel tag variables (such as
PY_WHEEL_PYTHON_TAG,PY_WHEEL_ABI_TAG, andPY_MAJOR_DOT_MINOR),and forward them through
current_py_toolchain. Attach the targetPython toolchain to
py_wheelso these variables are available bydefault, and expand make variables in
platformandpython_requires.