Skip to content

Commit 2331d66

Browse files
authored
Bazel cleanup (#7114)
## Summary This PR does a small round of Bazel 7 cleanup and dependency-wiring simplification on top of the already-working Bazel 7 / protobuf 6 baseline. The goal is not to change dependency versions or CI behavior, but to reduce migration-specific scaffolding where it is no longer needed, keep the remaining shims clearly documented, and preserve a clean, working build/test state. ## What changed ### Repository helper cleanup - simplified `third_party/repo.bzl` - removed unused `tb_http_archive` support for `build_file` / `link_files` - kept `tb_http_archive` focused on the behaviors still used in this repo: - mirrored URLs - optional patch application ### WORKSPACE cleanup - switched mirror-only repositories back to plain `http_archive` where the TensorBoard-specific helper was no longer adding value - kept `tb_http_archive(...)` only for repositories that still need: - patch application - repo mapping - clarified comments around the remaining Bazel/protobuf compatibility repos ### Compatibility shim review - verified that `third_party/compatibility_proxy` is still required by the current `rules_java` / protobuf loading path - kept it in place rather than removing a live dependency - verified that `third_party/protobuf_pip_deps` and `third_party/protobuf_pip_deps_setuptools` are still required by protobuf 6.31.1’s Bazel macros and Python packaging flow - improved documentation explaining why those repos still exist ## Why this PR is useful This PR keeps the Bazel 7 migration easier to maintain by: - removing dead helper code - narrowing custom repository logic to the cases that still need it - documenting the remaining compatibility shims with concrete rationale - avoiding behavior changes to the working build graph ## Validation Validated with: - `bazel fetch //tensorboard/...` - `bazel build //tensorboard/... --nobuild` - `bazel build //tensorboard/...` - `bazel test //tensorboard/plugins/debugger_v2:debugger_v2_plugin_test` - full local Bazel test runs after the cleanup changes
1 parent 03e8e04 commit 2331d66

5 files changed

Lines changed: 21 additions & 24 deletions

File tree

WORKSPACE

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ tb_http_archive(
293293
urls = tb_mirror_urls("https://github.com/bazelbuild/rules_cc/archive/refs/tags/0.1.0.tar.gz"),
294294
)
295295

296-
tb_http_archive(
296+
http_archive(
297297
name = "tb_rules_java",
298298
sha256 = "b2519fabcd360529071ade8732f208b3755489ed7668b118f8f90985c0e51324",
299299
strip_prefix = "rules_java-8.6.1",
@@ -305,11 +305,17 @@ local_repository(
305305
path = "third_party/compatibility_proxy",
306306
)
307307

308+
# Protobuf 6.31.1 still expects a pip-style requirements helper repo from its
309+
# WORKSPACE macros. TensorBoard only needs the narrow `install_deps()` /
310+
# `requirement()` surface that protobuf actually loads in this configuration.
308311
local_repository(
309312
name = "protobuf_pip_deps",
310313
path = "third_party/protobuf_pip_deps",
311314
)
312315

316+
# Protobuf's python/dist BUILD also references
317+
# `external/protobuf_pip_deps_setuptools/site-packages`, so keep this separate
318+
# repo shape even though it only vendors an empty placeholder tree here.
313319
local_repository(
314320
name = "protobuf_pip_deps_setuptools",
315321
path = "third_party/protobuf_pip_deps_setuptools",
@@ -350,14 +356,14 @@ protobuf_deps()
350356
#
351357
# Keep this aligned with TensorFlow 2.21's Bazel-side gRPC dependency so the
352358
# grpc plugin and protobuf repository stay on a known-compatible combination.
353-
tb_http_archive(
359+
http_archive(
354360
name = "com_github_grpc_grpc",
355361
sha256 = "dd6a2fa311ba8441bbefd2764c55b99136ff10f7ea42954be96006a2723d33fc",
356362
strip_prefix = "grpc-1.74.0",
357363
urls = tb_mirror_urls("https://github.com/grpc/grpc/archive/refs/tags/v1.74.0.tar.gz"),
358364
)
359365

360-
tb_http_archive(
366+
http_archive(
361367
name = "build_bazel_rules_swift",
362368
sha256 = "9919ed1d8dae509645bfd380537ae6501528d8de971caebed6d5185b9970dc4d",
363369
urls = tb_mirror_urls("https://github.com/bazelbuild/rules_swift/releases/download/2.1.1/rules_swift.2.1.1.tar.gz"),

tensorboard/plugins/debugger_v2/debugger_v2_plugin_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,7 @@ def testServeSourceFileContentOfThisTestFile(self):
14941494
data = json.loads(response.get_data())
14951495
self.assertEqual(data["host_name"], _HOST_NAME)
14961496
self.assertEqual(data["file_path"], _CURRENT_FILE_FULL_PATH)
1497-
with open(__file__, "r") as f:
1497+
with open(__file__, "r", newline="") as f:
14981498
lines = f.read().split("\n")
14991499
self.assertEqual(data["lines"], lines)
15001500

third_party/protobuf_pip_deps/requirements.bzl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
Protobuf's Bazel macros load a pip-style requirements helper that provides
44
`requirement()` and `install_deps()`. TensorBoard only needs a very small
55
subset of that surface here, so this file supplies just the labels
6-
protobuf actually asks for here.
6+
protobuf 6.31.1 actually asks for here:
7+
8+
* `install_deps()` from protobuf's WORKSPACE setup
9+
* `requirement("setuptools")` from `python/dist/BUILD.bazel`
10+
* `requirement("numpy")` from protobuf's numpy test target
711
"""
812

913
def requirement(name):
@@ -15,5 +19,5 @@ def requirement(name):
1519
fail("Unsupported protobuf pip dependency: %s" % name)
1620

1721
def install_deps():
18-
"""Compatibility no-op for callers that expect an install_deps symbol."""
22+
"""Compatibility no-op for protobuf's WORKSPACE dependency hook."""
1923
return None

third_party/protobuf_pip_deps_setuptools/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Protobuf's python/dist wheel genrule exports this exact external repo path on
2+
# PYTHONPATH, so preserve the repo/target shape even though TensorBoard only
3+
# needs an empty placeholder tree here.
14
filegroup(
25
name = "site_packages",
36
srcs = glob(["site-packages/**"]),

third_party/repo.bzl

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,8 @@ def tb_mirror_urls(url):
2323
url,
2424
]
2525

26-
def _get_link_dict(ctx, link_files, build_file):
27-
"""Builds the destination->source map for files linked into a repo rule."""
28-
link_dict = {ctx.path(v): ctx.path(Label(k)) for k, v in link_files.items()}
29-
if build_file:
30-
link_dict[ctx.path("BUILD.bazel")] = ctx.path(Label(build_file))
31-
return link_dict
32-
3326
def _tb_http_archive_impl(ctx):
34-
"""Repository-rule implementation with optional patching and linked files."""
35-
link_dict = _get_link_dict(ctx, ctx.attr.link_files, ctx.attr.build_file)
36-
27+
"""Repository-rule implementation with optional patching."""
3728
patch_files = ctx.attr.patch_file
3829
# Resolve patch labels up front so Bazel reports missing patch inputs before
3930
# download/extract work has completed.
@@ -53,11 +44,6 @@ def _tb_http_archive_impl(ctx):
5344
if patch_file:
5445
ctx.patch(patch_file, strip = 1)
5546

56-
# Link in any repository-local BUILD/link files after extraction and patching.
57-
for dst, src in link_dict.items():
58-
ctx.delete(dst)
59-
ctx.symlink(src, dst)
60-
6147
_tb_http_archive = repository_rule(
6248
implementation = _tb_http_archive_impl,
6349
attrs = {
@@ -66,13 +52,11 @@ _tb_http_archive = repository_rule(
6652
"strip_prefix": attr.string(),
6753
"type": attr.string(),
6854
"patch_file": attr.string_list(),
69-
"build_file": attr.string(),
70-
"link_files": attr.string_dict(),
7155
},
7256
)
7357

7458
def tb_http_archive(name, sha256, urls, **kwargs):
75-
"""Downloads a mirrored archive and creates a TensorBoard external repo."""
59+
"""Downloads a mirrored archive for TensorBoard-specific repo wiring."""
7660
if len(urls) < 2:
7761
fail("tb_http_archive(urls) must have redundant URLs.")
7862

0 commit comments

Comments
 (0)