Skip to content

Conversation

@frankslin
Copy link
Contributor

Use pythons_hub toolchains so Bazel py_test runs with the hermetic 3.12 runtime instead of the system Python.

Use pythons_hub toolchains so Bazel py_test runs with the hermetic 3.12 runtime instead of the system Python.
@BYVoid
Copy link
Owner

BYVoid commented Jan 14, 2026

Does Bazel download Python 3.12 if it is not installed?

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request registers the hermetic Python 3.12 toolchain in Bazel to ensure py_test targets run with a consistent Python runtime instead of relying on the system Python installation.

Changes:

  • Added use_repo to expose python_3_12 and pythons_hub repositories from the python extension
  • Registered the hermetic Python toolchains using register_toolchains("@pythons_hub//:all")

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@frankslin
Copy link
Contributor Author

Does Bazel download Python 3.12 if it is not installed?

Yes, it will. When using rules_python with bzlmod and a configured Python toolchain (e.g. python.toolchain(python_version = "3.12")), Bazel downloads a hermetic, prebuilt Python 3.12 runtime and uses it for both py_* rules and pip.parse.

This does not rely on the system Python and works even if Python 3.12 is not installed locally, as long as the toolchain is registered (e.g. via @pythons_hub).

@BYVoid BYVoid merged commit 6a47e83 into BYVoid:master Jan 14, 2026
30 checks passed
@frankslin frankslin deleted the fix/python-version-bazel branch January 14, 2026 06:18
frankslin added a commit to frankslin/OpenCC that referenced this pull request Jan 15, 2026
Use pythons_hub toolchains so Bazel py_test runs with the hermetic 3.12 runtime instead of the system Python.
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.

2 participants