diff --git a/MODULE.bazel b/MODULE.bazel index 1c7357715..3594fad8b 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -57,6 +57,9 @@ interpreters.configure( "20251031", ], ) +interpreters.toolchain( + python_version = "3.11", +) interpreters.toolchain( python_version = "3.13", ) @@ -65,6 +68,14 @@ use_repo( "python_interpreters", # Individual platform repos — must be visible so the uv extension can # reference the host interpreter for sdist configure tooling. + "python_3_11_aarch64_apple_darwin", + "python_3_11_aarch64_unknown_linux_gnu", + "python_3_11_aarch64_unknown_linux_musl", + "python_3_11_i686_pc_windows_msvc", + "python_3_11_x86_64_apple_darwin", + "python_3_11_x86_64_pc_windows_msvc", + "python_3_11_x86_64_unknown_linux_gnu", + "python_3_11_x86_64_unknown_linux_musl", "python_3_13_aarch64_apple_darwin", "python_3_13_aarch64_unknown_linux_gnu", "python_3_13_aarch64_unknown_linux_musl", diff --git a/py/private/py_pex_binary.bzl b/py/private/py_pex_binary.bzl index c1a8579df..baf51a072 100644 --- a/py/private/py_pex_binary.bzl +++ b/py/private/py_pex_binary.bzl @@ -38,6 +38,9 @@ exclude_paths = [ # these will match in bzlmod setup with --incompatible_use_plus_in_repo_names flag flipped. "rules_python++python+", "aspect_rules_py+/py/tools/", + # these will match the hermetic python interpreter from rules_py extension + "python_interpreters~", + "python_interpreters+", ] # determines if the given file is a `distinfo`, `dep` or a `source` @@ -54,6 +57,11 @@ def _map_srcs(f, workspace): if dest_path.find(exclude) != -1: return [] + if "_distutils_hack" in f.path: + return [] + if "distutils-precedence.pth" in f.path: + return [] + site_packages_i = f.path.find("site-packages") # If the path contains 'site-packages', treat it as a third party dep diff --git a/py/tests/py-pex-binary/BUILD.bazel b/py/tests/py-pex-binary/BUILD.bazel index 98b65ae44..1e4292580 100644 --- a/py/tests/py-pex-binary/BUILD.bazel +++ b/py/tests/py-pex-binary/BUILD.bazel @@ -4,10 +4,12 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test") load("//py:defs.bzl", "py_binary", "py_pex_binary") # Test that both single-file modules (six) and multi-file modules (cowsay) work with py_pex_binary. +# Also tests that py_pex_binary works with hermetic Python toolchains (python_version = 3.11). py_binary( name = "print_modules_bin", srcs = ["print_modules.py"], data = ["data.txt"], + python_version = "3.11", deps = [ "@pypi//cowsay", "@pypi//six",