Skip to content

Commit 9cb323e

Browse files
author
Shayan Hoshyari
committed
Remoe using py_internal in the config repo
1 parent 779623c commit 9cb323e

4 files changed

Lines changed: 6 additions & 25 deletions

File tree

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: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ 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 py_internal object needs to be accessed only from "tools/build_defs/python", so
22+
# we need to first put it there with a different name.
23+
load("//tools/build_defs/python/private:py_internal_renamed.bzl", "py_internal_renamed") # buildifier: disable=bzl-visibility
2424

25-
# NOTE: This is None prior to Bazel 7, as set by @rules_python_internal
26-
py_internal = py_internal_impl
25+
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:py_internal_bzl"],
2727
)

0 commit comments

Comments
 (0)