fix: define rules_python_internal earlier so Bazel 9 doesn't try to use PyInfo et al builtins (#2485)
For Bazel 9 workspace builds, if `@rules_python_internal` isn't defined
early enough,
an earlier version of `@rules_python` gets defined and the logic to not
use the builtin
PyInfo et al symbols doesn't occur. Since Bazel 9 doesn't have these
builtins, an error
occurs.
This seems to only happen if the main module is rules_python. The
example workspaces don't
see to have an issue. I'm not sure why, but it seems similar to the
behavior where
autoloading is disabled for specific repos, rules_python among them.
To fix, move the `@rules_python_internal` repo definition to be earlier
in the WORKSPACE
processing. With that repo defined, the conditional logic takes place,
and things seem
to be happy.
diff --git a/internal_dev_deps.bzl b/internal_dev_deps.bzl
index 8019681..e76ee48 100644
--- a/internal_dev_deps.bzl
+++ b/internal_dev_deps.bzl
@@ -16,6 +16,7 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", _http_archive = "http_archive", _http_file = "http_file")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
+load("//python/private:internal_config_repo.bzl", "internal_config_repo") # buildifier: disable=bzl-visibility
def http_archive(name, **kwargs):
maybe(
@@ -39,6 +40,7 @@
For dependencies needed by *users* of rules_python, see
python/private/py_repositories.bzl.
"""
+ internal_config_repo(name = "rules_python_internal")
http_archive(
name = "bazel_skylib",
diff --git a/internal_dev_setup.bzl b/internal_dev_setup.bzl
index 554ff92..26edcb9 100644
--- a/internal_dev_setup.bzl
+++ b/internal_dev_setup.bzl
@@ -25,14 +25,12 @@
load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains")
load("//:version.bzl", "SUPPORTED_BAZEL_VERSIONS")
load("//python:versions.bzl", "MINOR_MAPPING", "TOOL_VERSIONS")
-load("//python/private:internal_config_repo.bzl", "internal_config_repo") # buildifier: disable=bzl-visibility
load("//python/private:pythons_hub.bzl", "hub_repo") # buildifier: disable=bzl-visibility
load("//python/private/pypi:deps.bzl", "pypi_deps") # buildifier: disable=bzl-visibility
def rules_python_internal_setup():
"""Setup for development and testing of rules_python itself."""
- internal_config_repo(name = "rules_python_internal")
hub_repo(
name = "pythons_hub",
minor_mapping = MINOR_MAPPING,