--@rules_python//python/config_settings:python_version=3.13 not working by default
🐞 bug report
Affected Rule
The issue is caused by the rule: //python/config_settings:python_version
Is this a regression?
I don't think
Description
rules_python auto config doesn't seems to work when targeting python 3.13
🔬 Minimal Reproduction
using the examples/basic in https://github.com/pybind/pybind11_bazel
Protocol:
» git clone https://github.com/pybind/pybind11_bazel
» cd pybind11_bazel/examples/basic
» bazel run --@rules_python//python/config_settings:python_version=3.13 --toolchain_resolution_debug='@bazel_tools//tools/python:toolchain_type' @rules_python//python/bin:repl
expect to have the python interpreter...
note: target taken from the doc: https://rules-python.readthedocs.io/en/latest/repl.html#usage
🔥 Exception or Error
trace:
INFO: Options provided by the client:
Inherited 'common' options: --isatty=1 --terminal_columns=255
INFO: Reading rc options for 'run' from /usr/local/google/home/user/.../pybind11_bazel/examples/basic/.bazelrc:
Inherited 'common' options: --announce_rc --enable_bzlmod
WARNING: Build option --@@rules_python+//python/config_settings:python_version has changed, discarding analysis cache (this can be expensive, see https://bazel.build/advanced/performance/iteration-speed).
INFO: ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_8_aarch64-apple-darwin//:python_runtimes; mismatching config settings: _0000_python_3_8_aarch64-apple-darwin_3.8.20_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_8_aarch64-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0001_python_3_8_aarch64-unknown-linux-gnu_3.8.20_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_8_x86_64-apple-darwin//:python_runtimes; mismatching config settings: _0002_python_3_8_x86_64-apple-darwin_3.8.20_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_8_x86_64-pc-windows-msvc//:python_runtimes; mismatching config settings: _0003_python_3_8_x86_64-pc-windows-msvc_3.8.20_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_8_x86_64-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0004_python_3_8_x86_64-unknown-linux-gnu_3.8.20_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_9_aarch64-apple-darwin//:python_runtimes; mismatching config settings: _0005_python_3_9_aarch64-apple-darwin_3.9.23_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_9_aarch64-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0006_python_3_9_aarch64-unknown-linux-gnu_3.9.23_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_9_ppc64le-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0007_python_3_9_ppc64le-unknown-linux-gnu_3.9.23_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_9_riscv64-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0008_python_3_9_riscv64-unknown-linux-gnu_3.9.23_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_9_s390x-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0009_python_3_9_s390x-unknown-linux-gnu_3.9.23_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_9_x86_64-apple-darwin//:python_runtimes; mismatching config settings: _0010_python_3_9_x86_64-apple-darwin_3.9.23_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_9_x86_64-pc-windows-msvc//:python_runtimes; mismatching config settings: _0011_python_3_9_x86_64-pc-windows-msvc_3.9.23_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_9_x86_64-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0012_python_3_9_x86_64-unknown-linux-gnu_3.9.23_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_9_x86_64-unknown-linux-musl//:python_runtimes; mismatching config settings: _0013_python_3_9_x86_64-unknown-linux-musl_3.9.23_2, _is_py_linux_libc_musl
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_10_aarch64-apple-darwin//:python_runtimes; mismatching config settings: _0014_python_3_10_aarch64-apple-darwin_3.10.18_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_10_aarch64-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0015_python_3_10_aarch64-unknown-linux-gnu_3.10.18_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_10_ppc64le-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0016_python_3_10_ppc64le-unknown-linux-gnu_3.10.18_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_10_riscv64-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0017_python_3_10_riscv64-unknown-linux-gnu_3.10.18_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_10_s390x-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0018_python_3_10_s390x-unknown-linux-gnu_3.10.18_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_10_x86_64-apple-darwin//:python_runtimes; mismatching config settings: _0019_python_3_10_x86_64-apple-darwin_3.10.18_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_10_x86_64-pc-windows-msvc//:python_runtimes; mismatching config settings: _0020_python_3_10_x86_64-pc-windows-msvc_3.10.18_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_10_x86_64-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0021_python_3_10_x86_64-unknown-linux-gnu_3.10.18_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_10_x86_64-unknown-linux-musl//:python_runtimes; mismatching config settings: _0022_python_3_10_x86_64-unknown-linux-musl_3.10.18_2, _is_py_linux_libc_musl
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_12_aarch64-apple-darwin//:python_runtimes; mismatching config settings: _0023_python_3_12_aarch64-apple-darwin_3.12.11_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_12_aarch64-pc-windows-msvc//:python_runtimes; mismatching config settings: _0024_python_3_12_aarch64-pc-windows-msvc_3.12.11_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_12_aarch64-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0025_python_3_12_aarch64-unknown-linux-gnu_3.12.11_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_12_ppc64le-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0026_python_3_12_ppc64le-unknown-linux-gnu_3.12.11_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_12_riscv64-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0027_python_3_12_riscv64-unknown-linux-gnu_3.12.11_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_12_s390x-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0028_python_3_12_s390x-unknown-linux-gnu_3.12.11_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_12_x86_64-apple-darwin//:python_runtimes; mismatching config settings: _0029_python_3_12_x86_64-apple-darwin_3.12.11_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_12_x86_64-pc-windows-msvc//:python_runtimes; mismatching config settings: _0030_python_3_12_x86_64-pc-windows-msvc_3.12.11_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_12_x86_64-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0031_python_3_12_x86_64-unknown-linux-gnu_3.12.11_2
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_12_x86_64-unknown-linux-musl//:python_runtimes; mismatching config settings: _0032_python_3_12_x86_64-unknown-linux-musl_3.12.11_2, _is_py_linux_libc_musl
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_11_aarch64-apple-darwin//:python_runtimes; mismatching config settings: _0033_python_3_11_aarch64-apple-darwin_3.11.13_1
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_11_aarch64-pc-windows-msvc//:python_runtimes; mismatching config settings: _0034_python_3_11_aarch64-pc-windows-msvc_3.11.13_1
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_11_aarch64-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0035_python_3_11_aarch64-unknown-linux-gnu_3.11.13_1
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_11_ppc64le-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0036_python_3_11_ppc64le-unknown-linux-gnu_3.11.13_1
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_11_riscv64-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0037_python_3_11_riscv64-unknown-linux-gnu_3.11.13_1
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_11_s390x-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0038_python_3_11_s390x-unknown-linux-gnu_3.11.13_1
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_11_x86_64-apple-darwin//:python_runtimes; mismatching config settings: _0039_python_3_11_x86_64-apple-darwin_3.11.13_1
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_11_x86_64-pc-windows-msvc//:python_runtimes; mismatching config settings: _0040_python_3_11_x86_64-pc-windows-msvc_3.11.13_1
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_11_x86_64-unknown-linux-gnu//:python_runtimes; mismatching config settings: _0041_python_3_11_x86_64-unknown-linux-gnu_3.11.13_1
ToolchainResolution: Rejected toolchain @@rules_python++python+python_3_11_x86_64-unknown-linux-musl//:python_runtimes; mismatching config settings: _0042_python_3_11_x86_64-unknown-linux-musl_3.11.13_1, _is_py_linux_libc_musl
ToolchainResolution: Performing resolution of @@bazel_tools//tools/python:toolchain_type for target platform @@platforms//host:host
ToolchainResolution: No @@bazel_tools//tools/python:toolchain_type toolchain found for target platform @@platforms//host:host.
ERROR: /usr/local/google/home/corentinl/.cache/bazel/_bazel_corentinl/936ae04c13abe08bc62c225db7a774fc/external/rules_python+/python/bin/BUILD.bazel:27:15: While resolving toolchains for target @@rules_python+//python/bin:repl (f28129c): No matching toolchains found for types:
@@bazel_tools//tools/python:toolchain_type
To debug, rerun with --toolchain_resolution_debug='@@bazel_tools//tools/python:toolchain_type'
For more information on platforms or toolchains see https://bazel.build/concepts/platforms-intro.
ERROR: Analysis of target '@@rules_python+//python/bin:repl' failed; build aborted
INFO: Elapsed time: 0.148s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target
notice that python 3.13 (nor 3.14) is part of the search process...
🌍 Your Environment
Operating System:
» uname -a
Linux user.corp.google.com 6.12.32-1rodete1-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.32-1rodete1 (2025-06-26) x86_64 GNU/Linux
Output of bazel version:
» bazel version
WARNING: Invoking Bazel in batch mode since it is not invoked from within a workspace (below a directory having a MODULE.bazel file).
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
Build label: 8.4.2
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Wed Oct 01 16:46:46 2025 (1759337206)
Build timestamp: 1759337206
Build timestamp as int: 1759337206
Rules_python version:
» grep "rules_python" MODULE.bazel
bazel_dep(name = "rules_python", version = "1.6.3")
Anything else relevant?
Python 3.12 do work
bazel run --@rules_python//python/config_settings:python_version=3.12 --toolchain_resolution_debug='@bazel_tools//tools/python:toolchain_type' @rules_python//python/bin:repl
[...]
ToolchainResolution: Toolchain @@rules_python++python+python_3_12_x86_64-unknown-linux-gnu//:python_runtimes is compatible with target platform, searching for execution platforms:
ToolchainResolution: Compatible execution platform @@platforms//host:host
ToolchainResolution: All execution platforms have been assigned a @@bazel_tools//tools/python:toolchain_type toolchain, stopping
ToolchainResolution: Recap of selected @@bazel_tools//tools/python:toolchain_type toolchains for target platform @@platforms//host:host:
ToolchainResolution: Selected @@rules_python++python+python_3_12_x86_64-unknown-linux-gnu//:python_runtimes to run on execution platform @@platforms//host:host
INFO: Analyzed target @@rules_python+//python/bin:repl (0 packages loaded, 3001 targets configured).
INFO: Found 1 target...
Target @@rules_python+//python/bin:repl up-to-date:
bazel-bin/external/rules_python+/python/bin/repl
bazel-bin/external/rules_python+/python/bin/repl_py.py
INFO: Elapsed time: 0.261s, Critical Path: 0.01s
INFO: 1 process: 6 action cache hit, 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/external/rules_python+/python/bin/repl
Python 3.12.11 (main, Aug 8 2025, 17:06:48) [Clang 20.1.4 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
Is there a python.toolchain(python_version="3.13") call anywhere (in the root module or anywhere in the transitive modules)? What that call does is add 3.13 runtimes to the list of things to consider.
No AFAIK, Do you mean that python 3.13 and 3.14 are not available "by default" using rules_python 1.6.3 ?
They're available by default in the sense that rules_python has a mapping for 3.13 to backing URLs for the runtimes. They're not available by default in the sense that not every version is registered by default. This is because there's many runtimes, but in practice, only a handful are actually used. If a particular version is desired, then python.toolchain(...) must be called to register that something needs it.
Forgot to mention a caveat about 3.14: right now, only rc1 is part of the built in mappings.
As a general rule, rules_python doesn't provide strong guarantees about which particular runtime builds, versions, and platforms are available by default. What is baked in is a best effort thing. This simply because there's too many variations and they change relatively frequently (e.g. python-build-standalone has something like 1000+ builds of runtimes across a large matrix of platforms, versions, optimizations, etc that get rebuilt with newer build tool versions regularly).
Python 3.13 Toolchain
OK, registering a 3.13 toolchain make it work as expected...
git diff
diff --git a/examples/basic/MODULE.bazel b/examples/basic/MODULE.bazel
index df80726..e949733 100644
--- a/examples/basic/MODULE.bazel
+++ b/examples/basic/MODULE.bazel
@@ -1,5 +1,11 @@
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "rules_python", version = "1.6.3")
+
+python = use_extension("@rules_python//python/extensions:python.bzl", "python")
+python.toolchain(
+ python_version = "3.13",
+)
+
bazel_dep(name = "pybind11_bazel")
local_path_override(
module_name = "pybind11_bazel",
got as expected python 3.13.6
bazel run @rules_python//python/bin:python --@rules_python//python/config_settings:python_version=3.13 -- --version
Starting local Bazel server (8.4.2) and connecting to it...
INFO: Options provided by the client:
Inherited 'common' options: --isatty=1 --terminal_columns=127
INFO: Reading rc options for 'run' from /usr/local/google/home/user/work/pybind11_bazel/examples/basic/.bazelrc:
Inherited 'common' options: --announce_rc --enable_bzlmod
INFO: Analyzed target @@rules_python+//python/bin:python (67 packages loaded, 2542 targets configured).
INFO: Found 1 target...
Target @@rules_python+//python/bin:python up-to-date:
bazel-bin/external/rules_python+/python/bin/python3
INFO: Elapsed time: 6.981s, Critical Path: 0.38s
INFO: 5 processes: 5 internal.
INFO: Build completed successfully, 5 total actions
INFO: Running command line: bazel-bin/external/rules_python+/python/bin/python3 <args omitted>
Python 3.13.6
Python 3.14 Toolchain
same with python 3.14 and we got Python 3.14.0rc1 as expected in the version.bzl https://github.com/bazel-contrib/rules_python/blob/1ebc93f19de1420ea12c59e3bfb315fec92e54f5/python/versions.bzl#L867-L868
Default supported version
They're not available by default in the sense that not every version is registered by default.
While I agree that "registering" all python versions is unpractical, I would expect that, at the time of the rules_python release, the current default python (i.e. 3.13) would have been part of the version search by default without needing a manual registration...
Also I could point out that version 3.8 is already end of life so should not be part of the "default search" anymore imho... note: Same with 3.9 which is soon EOL in few days (aka drop 3.9 and add 3.14 (once 3.14.0 is out)) for the next release of rules_python note2: since google3 move to python 3.10, we can also expect lots of google owned source code not compatible anymore with python<3.10 ...
i.e. the Todo/Issue/PR List:
- [ ] Remove Python 3.8 from registered toolchain (EOL 2024/10/07)
- [ ] Remove Python 3.9 from registered toolchain (EOL 2025/10/31)
- [ ] Add Python 3.13 to registered toolchain (Release 2024/10/07 PEP 719)
- [ ] Add Python 3.14 to registered toolchain (Soon Release 2025/10 PEP 745)
ref:
- https://devguide.python.org/versions/
- https://endoflife.date/python
ps: Feel free to close this issue once read ;)
The legacy toolchain removal is tracked as part of https://github.com/bazel-contrib/rules_python/issues/2704, so this issue can stay open if we want to continue discussing how we set the defaults for future. The feature request may be to register all of the versions in the mapping by default. Any special treatment of the versions might be something that we may want to leave out.
@aignas nit: can you use a bullet list for the issue so github magically display the title ? ;)
see:
* #2704
render to:
- #2704
got an issue with 3.13 toolchain, everything explain here:
- https://github.com/google/or-tools/pull/4863#issuecomment-3390087181
TLDR: AFAIU toolchain 3.13 may use an old cython version which has undefined symbol: _PyThreadState_UncheckedGet aka
can't be use in a project using pthread x pybind11 x rules_python.
note: Didn't manage to reproduce it in a MRE but easy to reproduce with google/or-tools since we provide dockerfile for local ci testing (see issue for the protocol)
@aignas nit: can you use a bullet list for the issue so github magically display the title ? ;)
You can hover on the link to see the title. :)