-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Description
I'm experiencing the following issue and i'm completely lost here.
While the production-setup is a bit more complex including cibuildwheel, i think the following example demonstrates my issue:
MODULE.bzl
(excerpt)
bazel_dep(name = "rules_python", version = "1.5.1")
# We do want to enforce a local toolchain as we expect this to run in an isolated container provided by cibuildwheel
# START TOOLCHAIN AUTO REGISTER
local_runtime_repo = use_repo_rule(
"@rules_python//python/local_toolchains:repos.bzl",
"local_runtime_repo",
# dev_dependency = True, current bazel 8.3.1 doesn't accept it: remove it (although in rules_python docs)
)
local_runtime_toolchains_repo = use_repo_rule(
"@rules_python//python/local_toolchains:repos.bzl",
"local_runtime_toolchains_repo",
# dev_dependency = True, current bazel 8.3.1 doesn't accept it: remove it (although in rules_python docs)
)
# Step 1: Define the Python runtime
local_runtime_repo(
name = "local_python3",
interpreter_path = "python3",
on_failure = "fail",
)
# Step 2: Create toolchains for the runtimes
local_runtime_toolchains_repo(
name = "local_toolchains",
runtimes = ["local_python3"],
# TIP: The `target_settings` arg can be used to activate them based on
# command line flags; see docs below.
)
# Step 3: Register the toolchains
register_toolchains("@local_toolchains//:all", dev_dependency = True)
# END TOOLCHAIN AUTO REGISTER
bazel_dep(name = "pybind11_bazel", version = "2.13.6")
bazel_dep(name = "pybind11_protobuf", version = "0.0.0-20250210-f02a2b7")
The toolchain registering actually makes a difference as seen in the following output (and 3.10 is working as expected with auto register):
# WITH toolchain auto register
bazelisk run @rules_python//python/bin:python
Python 3.10.12 (main, May 27 2025, 17:12:29) [GCC 11.4.0] on linux
# WITHOUT toolchain auto register
bazelisk run @rules_python//python/bin:python
Python 3.11.13 (main, Jun 9 2025, 18:12:55) [Clang 20.1.4 ] on linux
But now the issue:
BUILD
bazelisk build //tensor-api-lib/wrapper/pytensorlib:_pytensorlib.so
TRAVERSE
cd bazel-bin/tensor-api-lib/wrapper/pytensorlib/
LOAD
python3
Python 3.10.12 (main, May 27 2025, 17:12:29) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import _pytensorlib.so
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: Python version mismatch: module was compiled for Python 3.12, but the interpreter version is incompatible: 3.10.12 (main, May 27 2025, 17:12:29) [GCC 11.4.0].
>>>
I never had those problems with an old WORKSPACE setup (and some older versions).
I'm somewhat convinced, that this is the right repository to ask (opposed to rules_python
).
Any ideas?
Thanks
Metadata
Metadata
Assignees
Labels
No labels