10 Commits
Author SHA1 Message Date
Yurii Topin 9f6a3bf72c Use Hermetic Python from rules_ml_toolchain
All essential C++, Python, CUDA, and SYCL (oneAPI) toolchains have been consolidated into rules_ml_toolchain. This repository now includes dedicated tests to ensure early bug detection whenever toolchain changes occur.

To ensure backward compatibility, logic in specific @xla//third_party/py files has been replaced with stubs. This allows dependent projects to transition to the new files gradually without breaking. Additionally, the initialization of rules_python and related repositories (including necessary patches) will remain within XLA. This is because MODULE.bazel initialization must rely strictly on local repository files and cannot utilize remote resources.

PiperOrigin-RevId: 901027238
2026-04-16 19:51:01 -07:00
Ezekiel Calubaquib 0fa15d76e6 Update rules_python to latest 1.8.4 for tensorflow and xla. Doing so would enable us to use latest feature which includes a venv layout. This latest version also introduce stricter hermeticity which was first introduce in 1.7.0 as seen in logs:
- https://rules-python.readthedocs.io/en/latest/changelog.html#v1-7.0 (see sys.path order change and bootstraping)
- pipstar flag default has been flipped to be on by default. It can be disabled through RULES_PYTHON_ENABLE_PIPSTAR=0 environment variable

1. Replace native bazel py_binary/py_library rules with rules_python's py_binary and py_library to selected BUILD files affected with updated to avoid %interpreter% error
2. Export PYTHONPATH build_pip_package.py
3. Add new commit sha and version for rules_python 1.8.4. Rules_python 1.8.4 added "scope" params to bool_flag and string_flag which is incompatible with bazel 7.7.0 used by TF, for now we can patch it
5. add flags RULES_PYTHON_ENABLE_PIPSTAR=0
6. Update patches for rules_python

NOTE: below are important

7. Due to rules_python 1.8.4 not differentiating between freethread and non-freethread see: https://github.com/bazel-contrib/rules_python/blob/1.8.4/python/private/pypi/pip_repository.bzl#L111 we need to inject --abi and cp<version>t to --extra_pip_args for rules_python to download specific packages used for freethreaded if HERMETIC_PYTHON_VERSION=<version>-ft is used.

8. Update the _get_injected_local_wheels custom rule to inject a --find-links rather than <package_name> @ <local prefix> as rules_python 1.8.4 seems to drop the package causing it to not find the wheels

PiperOrigin-RevId: 878583333
2026-03-04 11:30:20 -08:00
Ezekiel Calubaquib da5fe834d2 Rollback update to rules_python 1.8.3 from 1.6.0 as wheel builds broke
Reverts 7e078b68a5

PiperOrigin-RevId: 869263470
2026-02-12 10:21:24 -08:00
Ezekiel Calubaquib 7e078b68a5 Update rules_python to latest 1.8.3 for tensorflow and xla. Doing so would enable us to use latest feature which includes a venv layout. This latest version also introduce stricter hermeticity which was first introduce in 1.7.0 as seen in logs:
https://rules-python.readthedocs.io/en/latest/changelog.html#v1-7.0 (see sys.path order change and bootstraping)

1. Replace native bazel py_binary/py_library rules with rules_python's py_binary and py_library to selected BUILD files affected with updated to avoid %interpreter% error
2. Export PYTHONPATH build_pip_package.py
3. Add new commit sha and version for rules_python 1.8.3
4. Rules_python 1.8.3 added "scope" params to bool_flag and string_flag which is incompatible with bazel 7.7.0 used by TF, for now we can patch it

PiperOrigin-RevId: 869056688
2026-02-12 00:12:59 -08:00
A. Unique TensorFlower a83ab83e5f Squashing commits after sync tool breakage
PiperOrigin-RevId: 843718817
2025-12-12 09:39:29 -08:00
A. Unique TensorFlower 94e89d1103 Fix freethreaded builds by passing HERMETIC_PYTHON_VERSION_KIND in repository rules.
The problem was that `@python_<>_host` repository wasn't aware of the python type (controlled by the build flag `@rules_python//python/config_settings:py_freethreaded`) and selected the first candidate, e.g. GIL version of the python.

PiperOrigin-RevId: 808825370
2025-09-18 18:54:36 -07:00
A. Unique TensorFlower 3eae65361b Update rules_python to v1.6 in XLA and TensorFlow projects.
`com_google_protobuf` and `rules_cc` initialization was moved to `python_init_rules` macros.

The JAX repository update will be done [in the next step](https://github.com/jax-ml/jax/pull/31709)

PiperOrigin-RevId: 808689003
2025-09-18 12:30:45 -07:00
Peter Hawkins 552c1ee1c7 Patch rules_python to support free-threading.
Forked from https://github.com/openxla/xla/pull/25183

Without this change rules_python doesn't correctly install free-threaded wheels for a free-threaded Python build.

PiperOrigin-RevId: 749128015
2025-04-18 14:14:16 -07:00
Vadym Matsishevskyi bb90355488 Add more flexible custom hermetic Python setup
PiperOrigin-RevId: 700855957
2024-11-27 18:18:35 -08:00
Vadym Matsishevskyi 3bf2ac3b77 Use hermetic Python in TSL and XLA
PiperOrigin-RevId: 634094641
2024-05-15 16:48:11 -07:00