Hi!
We are trying to migrate to the an hermetic toolchain for python with rules_python. We are currently using python from our development environment machine.
We use external dependencies that does not work with rules_python since they depend on locally installed packages.
I want to start using rules_python for our internal python targets first.
This is what I have tried:
MODULE.bazel
bazel_dep(name = "rules_python", version = "0.33.2")
register_toolchains("@bazel_tools//tools/python:autodetecting_toolchain")
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(python_version = "3.10")
use_repo(python, "python_3_10", "python_versions", "pythons_hub")
BUILD
load("@python_versions//3.10:defs.bzl", "py_binary")
py_binary(
name = "main",
srcs = ["main.py"],
)
I was expecting that ":main" would use the hermetic toolchain for python, and if I skipped the load, it would use the version from the development environment machine , but it does not work. The example will use python from the development environment machine
If I move the following line last in MODULE.bazel, the hermetic python toolchain will always be used.
register_toolchains("@bazel_tools//tools/python:autodetecting_toolchain")
And there is no way I can can force usage of the dev env version.