From da73e38b8f678602d4df6f51428eb46fc05403b0 Mon Sep 17 00:00:00 2001 From: Brett McLarnon Date: Fri, 7 Mar 2025 10:30:39 -0800 Subject: [PATCH] Replace rules_pkg patch with `bootstrap_impl=script`. https://github.com/bazelbuild/rules_python/issues/691 removed the need for a system python installation, removing the need for a pkg_tar-specific patch. This fix requires rules_python >= 0.33.0 and bazel >= 7.0.0. Change-Id: I3f5a3ffb99ec4916908a927aaef3486072e43a92 --- .bazelrc | 2 ++ .bazelversion | 2 +- WORKSPACE | 15 +++++++-------- third_party/rules_pkg/BUILD | 0 third_party/rules_pkg/tar.patch | 32 -------------------------------- 5 files changed, 10 insertions(+), 41 deletions(-) delete mode 100644 third_party/rules_pkg/BUILD delete mode 100644 third_party/rules_pkg/tar.patch diff --git a/.bazelrc b/.bazelrc index 9201ce9..9757207 100644 --- a/.bazelrc +++ b/.bazelrc @@ -4,6 +4,8 @@ build --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 --incompatible_strict_act build --show_timestamps build --@rules_rust//rust/toolchain/channel=nightly build --incompatible_merge_fixed_and_default_shell_env # https://github.com/bazelbuild/rules_rust/issues/2665 +build --@rules_python//python/config_settings:bootstrap_impl=script # https://github.com/bazelbuild/rules_python/issues/691 +common --noenable_bzlmod # Settings for remote build execution. build:tcp-remote --experimental_allow_tags_propagation diff --git a/.bazelversion b/.bazelversion index f22d756..18bb418 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -6.5.0 +7.5.0 diff --git a/WORKSPACE b/WORKSPACE index 155d6b0..bc065f7 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -34,6 +34,13 @@ http_archive( url = "https://github.com/bazelbuild/bazel-toolchains/archive/refs/tags/v5.1.2.tar.gz", ) +http_archive( + name = "rules_python", + sha256 = "dc6e2756130fafb90273587003659cadd1a2dfef3f6464c227794cdc01ebf70e", + strip_prefix = "rules_python-0.33.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.33.0/rules_python-0.33.0.tar.gz", +) + http_archive( name = "com_google_protobuf", sha256 = "1535151efbc7893f38b0578e83cac584f2819974f065698976989ec71c1af84a", @@ -47,7 +54,6 @@ protobuf_deps() http_archive( name = "rules_pkg", - patches = ["//third_party/rules_pkg:tar.patch"], sha256 = "d20c951960ed77cb7b341c2a59488534e494d5ad1d30c4818c736d57772a9fef", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/1.0.1/rules_pkg-1.0.1.tar.gz", @@ -141,13 +147,6 @@ gcc_register_toolchain( ], ) -http_archive( - name = "rules_python", - sha256 = "d71d2c67e0bce986e1c5a7731b4693226867c45bfe0b7c5e0067228a536fc580", - strip_prefix = "rules_python-0.29.0", - url = "https://github.com/bazelbuild/rules_python/releases/download/0.29.0/rules_python-0.29.0.tar.gz", -) - load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains") py_repositories() diff --git a/third_party/rules_pkg/BUILD b/third_party/rules_pkg/BUILD deleted file mode 100644 index e69de29..0000000 diff --git a/third_party/rules_pkg/tar.patch b/third_party/rules_pkg/tar.patch deleted file mode 100644 index 8113c07..0000000 --- a/third_party/rules_pkg/tar.patch +++ /dev/null @@ -1,32 +0,0 @@ -# Fix pkg_tar to work with a in-build python interpreter. -# See https://github.com/bazelbuild/rules_pkg/issues/926. ---- pkg/private/tar/tar.bzl -+++ pkg/private/tar/tar.bzl -@@ -187,16 +187,21 @@ -+ py3_runtime = ctx.toolchains["@bazel_tools//tools/python:toolchain_type"].py3_runtime - ctx.actions.run( - mnemonic = "PackageTar", - progress_message = "Writing: %s" % output_file.path, - inputs = inputs, -- tools = [ctx.executable.compressor] if ctx.executable.compressor else [], -+ tools = ( -+ [ctx.executable.compressor] if ctx.executable.compressor else [] + -+ [py3_runtime.files] if py3_runtime.files else [] -+ ), - executable = ctx.executable._build_tar, - arguments = [args], - outputs = [output_file], - env = { - "LANG": "en_US.UTF-8", - "LC_CTYPE": "UTF-8", - "PYTHONIOENCODING": "UTF-8", - "PYTHONUTF8": "1", -+ "PATH": "$PATH" + (":" + py3_runtime.interpreter.dirname if py3_runtime.interpreter else ""), - }, - use_default_shell_env = True, - ) -@@ -310,3 +315,4 @@ - ), - }, -+ toolchains = ["@bazel_tools//tools/python:toolchain_type"], - ) \ No newline at end of file