Skip to content

Commit 9571e2d

Browse files
shayanhoshyariShayan Hoshyarigemini-code-assist[bot]
authored
chore (py_internal): Remove roundtrip of putting py_internal in the config repo (#3522)
I was reading on `py_internal` and found this opportunity for simplification. When there was support for Bazel `< 7` `py_internal` was in `@rules_python_internal`, because it had to be set to None depending on Bazel version. #3282 removed Bazel `< 7` support shims, and made `py_internal` not depend on Bazel version. So now there no need to put it in `@rules_python_internal`. --------- Co-authored-by: Shayan Hoshyari <hoshyari@adobe.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 779623c commit 9571e2d

File tree

4 files changed

+8
-25
lines changed

4 files changed

+8
-25
lines changed

python/private/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ bzl_library(
454454
bzl_library(
455455
name = "py_internal_bzl",
456456
srcs = ["py_internal.bzl"],
457-
deps = ["@rules_python_internal//:py_internal_bzl"],
457+
deps = ["//tools/build_defs/python/private:py_internal_renamed_bzl"],
458458
)
459459

460460
bzl_library(

python/private/internal_config_repo.bzl

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@ config = struct(
4242
)
4343
"""
4444

45-
# The py_internal symbol is only accessible from within @rules_python, so we have to
46-
# load it from there and re-export it so that rules_python can later load it.
47-
_PY_INTERNAL_SHIM = """
48-
load("@rules_python//tools/build_defs/python/private:py_internal_renamed.bzl", "py_internal_renamed")
49-
py_internal_impl = py_internal_renamed
50-
"""
51-
5245
ROOT_BUILD_TEMPLATE = """
5346
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
5447
@@ -63,12 +56,6 @@ bzl_library(
6356
srcs = ["rules_python_config.bzl"]
6457
)
6558
66-
bzl_library(
67-
name = "py_internal_bzl",
68-
srcs = ["py_internal.bzl"],
69-
deps = [{py_internal_dep}],
70-
)
71-
7259
bzl_library(
7360
name = "extra_transition_settings_bzl",
7461
srcs = ["extra_transition_settings.bzl"],
@@ -128,14 +115,9 @@ def _internal_config_repo_impl(rctx):
128115
bazel_10_or_later = str(bazel_major_version > 9),
129116
))
130117

131-
shim_content = _PY_INTERNAL_SHIM
132-
py_internal_dep = '"@rules_python//tools/build_defs/python/private:py_internal_renamed_bzl"'
133-
134118
rctx.file("BUILD", ROOT_BUILD_TEMPLATE.format(
135-
py_internal_dep = py_internal_dep,
136119
visibility = "@rules_python//:__subpackages__",
137120
))
138-
rctx.file("py_internal.bzl", shim_content)
139121

140122
rctx.file(
141123
"extra_transition_settings.bzl",

python/private/py_internal.bzl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ Re-exports the restricted-use py_internal helper under its original name.
1818
These may change at any time and are closely coupled to the rule implementation.
1919
"""
2020

21-
# The py_internal global is only available in Bazel 7+, so loading of it
22-
# must go through a repo rule with Bazel version detection logic.
23-
load("@rules_python_internal//:py_internal.bzl", "py_internal_impl")
21+
# The native `py_internal` object is only visible to Starlark files under
22+
# `tools/build_defs/python`. To access it from `//python/private`, we use an
23+
# indirection through `//tools/build_defs/python/private/py_internal_renamed.bzl`,
24+
# which re-exports it under a different name.
25+
load("//tools/build_defs/python/private:py_internal_renamed.bzl", "py_internal_renamed") # buildifier: disable=bzl-visibility
2426

25-
# NOTE: This is None prior to Bazel 7, as set by @rules_python_internal
26-
py_internal = py_internal_impl
27+
py_internal = py_internal_renamed

tools/build_defs/python/private/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ filegroup(
2323
bzl_library(
2424
name = "py_internal_renamed_bzl",
2525
srcs = ["py_internal_renamed.bzl"],
26-
visibility = ["@rules_python_internal//:__subpackages__"],
26+
visibility = ["//python/private:__pkg__"],
2727
)

0 commit comments

Comments
 (0)