From ce8ba3df131f4086baa0a16ae4fcf36e0bb5e742 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Fri, 6 Feb 2026 17:48:03 -0700 Subject: [PATCH] fix: document module extensions, not workspace repositories Users are expected to setup rules_py using MODULE.bazel now --- .github/workflows/release_docs.sh | 13 +++++++++ .github/workflows/release_prep.sh | 34 ------------------------ BUILD.bazel | 2 ++ py/BUILD.bazel | 37 ++++++++------------------ py/repositories.bzl | 44 ------------------------------- 5 files changed, 26 insertions(+), 104 deletions(-) create mode 100755 .github/workflows/release_docs.sh delete mode 100644 py/repositories.bzl diff --git a/.github/workflows/release_docs.sh b/.github/workflows/release_docs.sh new file mode 100755 index 00000000..d0198b32 --- /dev/null +++ b/.github/workflows/release_docs.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# Add generated API docs to the release +# see https://github.com/bazelbuild/bazel-central-registry/blob/main/docs/stardoc.md +set -o errexit -o nounset -o pipefail + +docs="$(mktemp -d)" +targets="$(mktemp)" +out=$1 +bazel --output_base="$docs" query --output=label --output_file="$targets" 'kind("starlark_doc_extract rule", //...)' +bazel --output_base="$docs" build --target_pattern_file="$targets" +tar --create --auto-compress \ + --directory "$(bazel --output_base="$docs" info bazel-bin)" \ + --file "${out}" . diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh index f754b10a..8988dd7a 100755 --- a/.github/workflows/release_prep.sh +++ b/.github/workflows/release_prep.sh @@ -50,8 +50,6 @@ tar --create --auto-compress \ --file "$GITHUB_WORKSPACE/${ARCHIVE%.tar.gz}.docs.tar.gz" . cat << EOF -## Using [Bzlmod] with Bazel 6: - Add to your \`MODULE.bazel\` file: \`\`\`starlark @@ -67,36 +65,4 @@ python.toolchain( ) \`\`\` -[Bzlmod]: https://bazel.build/build/bzlmod - -## Using WORKSPACE - -\`\`\`starlark -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -http_archive( - name = "aspect_rules_py", - sha256 = "${SHA}", - strip_prefix = "${PREFIX}", - url = "https://github.com/aspect-build/rules_py/releases/download/${TAG}/${ARCHIVE}", -) - -load("@aspect_rules_py//py:repositories.bzl", "rules_py_dependencies") - -rules_py_dependencies() - -load("@aspect_rules_py//py:toolchains.bzl", "rules_py_toolchains") - -rules_py_toolchains() - -# "Installation" for rules_python -load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains") - -python_register_toolchains( - name = "python_toolchain", - python_version = "3.9", -) - -py_repositories() -\`\`\` - EOF diff --git a/BUILD.bazel b/BUILD.bazel index 0fcf1b81..efdc898c 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,5 +1,7 @@ load("@gazelle//:def.bzl", "gazelle") load("@rules_python//python/pip_install:requirements.bzl", "compile_pip_requirements") + +# buildifier: disable=bzl-visibility load("//uv/private/manifest:defs.bzl", "gazelle_python_manifest") # gazelle:exclude internal_python_deps.bzl diff --git a/py/BUILD.bazel b/py/BUILD.bazel index fd124aeb..615f86d0 100644 --- a/py/BUILD.bazel +++ b/py/BUILD.bazel @@ -3,24 +3,13 @@ load("@bazel_lib//:bzl_library.bzl", "bzl_library") # For Bazel 6.x compatibility, since # PyRuntimeInfo shipped only with Bazel 7 # Users can set, e.g. --@aspect_rules_py//py:interpreter_version=3.9.18 +# TODO(2.0): remove since Bazel 6 is no longer LTS alias( name = "interpreter_version", actual = "@rules_python//python/config_settings:python_version", visibility = ["//visibility:public"], ) -bzl_library( - name = "repositories", - srcs = ["repositories.bzl"], - visibility = ["//visibility:public"], - deps = [ - "//py/private/toolchain:autodetecting", - "@bazel_tools//tools/build_defs/repo:cache.bzl", - "@bazel_tools//tools/build_defs/repo:http.bzl", - "@bazel_tools//tools/build_defs/repo:utils.bzl", - ], -) - bzl_library( name = "defs", srcs = ["defs.bzl"], @@ -39,20 +28,16 @@ bzl_library( ], ) -# This needs to dep on @aspect_tools_telemetry_report but we don't have that in WORKSPACE -# gazelle:exclude extensions.bzl -# bzl_library( -# name = "extensions", -# srcs = [ -# "extensions.bzl", -# "@aspect_tools_telemetry_report//:defs.bzl", -# ], -# visibility = ["//visibility:public"], -# deps = [ -# ":toolchains", -# "//py/private/release:version", -# ], -# ) +bzl_library( + name = "extensions", + srcs = ["extensions.bzl"], + visibility = ["//visibility:public"], + deps = [ + ":toolchains", + "//py/private/release:version", + "@aspect_tools_telemetry_report//:defs.bzl", + ], +) bzl_library( name = "toolchains", diff --git a/py/repositories.bzl b/py/repositories.bzl deleted file mode 100644 index e4b47cf0..00000000 --- a/py/repositories.bzl +++ /dev/null @@ -1,44 +0,0 @@ -"""Declare runtime dependencies - -These are needed for local dev, and users must install them as well. -See https://docs.bazel.build/versions/main/skylark/deploying.html#dependencies -""" - -load("@bazel_tools//tools/build_defs/repo:http.bzl", _http_archive = "http_archive") -load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") - -def http_archive(name, **kwargs): - maybe(_http_archive, name = name, **kwargs) - -# WARNING: any changes in this function may be BREAKING CHANGES for users -# because we'll fetch a dependency which may be different from one that -# they were previously fetching later in their WORKSPACE setup, and now -# ours took precedence. Such breakages are challenging for users, so any -# changes in this function should be marked as BREAKING in the commit message -# and released only in semver majors. - -# buildifier: disable=unnamed-macro -def rules_py_dependencies(): - """Fetch rules_py's dependencies""" - - http_archive( - name = "bazel_lib", - sha256 = "0758ace949a93f709230a8e08ef35c5f0aacae2ff5d219b27da1d21d8233a709", - strip_prefix = "bazel-lib-3.0.0-rc.0", - url = "https://github.com/bazel-contrib/bazel-lib/releases/download/v3.0.0-rc.0/bazel-lib-v3.0.0-rc.0.tar.gz", - ) - - # The minimal version of bazel_skylib we require - http_archive( - name = "bazel_skylib", - sha256 = "e3fea03ff75a9821e84199466799ba560dbaebb299c655b5307f4df1e5970696", - strip_prefix = "bazel-skylib-1.7.1", - url = "https://github.com/bazelbuild/bazel-skylib/archive/refs/tags/1.7.1.tar.gz", - ) - - http_archive( - name = "rules_python", - sha256 = "c68bdc4fbec25de5b5493b8819cfc877c4ea299c0dcb15c244c5a00208cde311", - strip_prefix = "rules_python-0.31.0", - url = "https://github.com/bazelbuild/rules_python/releases/download/0.31.0/rules_python-0.31.0.tar.gz", - )