Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions .github/workflows/create_archive_and_notes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,25 @@ fi
# A prefix is added to better match the GitHub generated archives.
PREFIX="rules_python-${TAG}"
ARCHIVE="rules_python-$TAG.tar.gz"
# TODO(https://github.com/bazel-contrib/rules_python/issues/4250): Add
# artifacts_manifest.json to the release archive.
git archive --format=tar "--prefix=${PREFIX}/" "$TAG" | gzip > "$ARCHIVE"
sed --in-place 's/^TOOL_DEPS_DEV_ONLY = False$/TOOL_DEPS_DEV_ONLY = True/' MODULE.bazel
# Verify that sed actually matched and modified the line (sed exits 0 even if no
# substitution occurred).
grep -q '^TOOL_DEPS_DEV_ONLY = True$' MODULE.bazel
# --add-file appends extra files to the archive without replacing tracked files
# from $TAG, so pathspec ":!..." excludes the committed files to avoid duplicate
# tar entries (where the committed ones would overwrite the modified ones on
# extraction).
git archive \
--format=tar \
"--prefix=${PREFIX}/" \
"--add-file=MODULE.bazel" \
"--prefix=${PREFIX}/python/private/" \
"--add-file=artifacts_manifest.json" \
"--prefix=${PREFIX}/" \
"$TAG" \
. \
":!MODULE.bazel" \
":!python/private/artifacts_manifest.json" | gzip > "$ARCHIVE"
SHA=$(shasum -a 256 "$ARCHIVE" | awk '{print $1}')

cat > release_notes.txt << EOF
Expand Down
5 changes: 4 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ exports_files([
])

exports_files(
[".bazelversion"],
[
".bazelversion",
"MODULE.bazel",
],
visibility = ["//tests:__subpackages__"],
)

Expand Down
51 changes: 31 additions & 20 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ bazel_dep(name = "toml.bzl", version = "0.4.1")
# Use py_proto_library directly from protobuf repository
bazel_dep(name = "protobuf", version = "29.0-rc2", repo_name = "com_google_protobuf")

# False in git so source checkouts build and enable Rust tools by default;
# rewritten to True in release archives (which bundle prebuilt binaries).
TOOL_DEPS_DEV_ONLY = False

rules_python_config = use_extension("//python/extensions:config.bzl", "config")
rules_python_config.internal_configure(
tool_deps_dev_only = TOOL_DEPS_DEV_ONLY,
)
use_repo(
rules_python_config,
"pypi__build",
Expand All @@ -34,8 +41,11 @@ use_repo(
"pypi__wheel",
"pypi__zipp",
"rules_python_internal",
"rules_python_tools",
)

register_toolchains("@rules_python_tools//toolchains:all")

# We need to do another use_extension call to expose the "pythons_hub"
# repo.
python = use_extension("//python/extensions:python.bzl", "python")
Expand Down Expand Up @@ -89,25 +99,16 @@ pip.dep(name = "pytest-randomly")
pip.dep(name = "pytest-shard")
use_repo(pip, "pypi", "rules_python_publish_deps")

# ===== DEV ONLY DEPS AND SETUP BELOW HERE =====
bazel_dep(name = "sphinxdocs", version = "0.0.0", dev_dependency = True)
local_path_override(
module_name = "sphinxdocs",
path = "sphinxdocs",
bazel_dep(
name = "rules_rust",
version = "0.73.0",
dev_dependency = TOOL_DEPS_DEV_ONLY,
)

bazel_dep(name = "rules_bazel_integration_test", version = "0.27.0", dev_dependency = True)
bazel_dep(name = "rules_testing", version = "0.6.0", dev_dependency = True)
bazel_dep(name = "rules_shell", version = "0.3.0", dev_dependency = True)
bazel_dep(name = "rules_multirun", version = "0.9.0", dev_dependency = True)
bazel_dep(name = "bazel_ci_rules", version = "1.0.0", dev_dependency = True)
bazel_dep(name = "rules_pkg", version = "1.2.0", dev_dependency = True)
bazel_dep(name = "rules_rust", version = "0.73.0", dev_dependency = True)

rust_crates = use_extension(
"@rules_rust//crate_universe:extensions.bzl",
"crate",
dev_dependency = True,
dev_dependency = TOOL_DEPS_DEV_ONLY,
)
rust_crates.spec(
package = "sha2",
Expand All @@ -119,6 +120,8 @@ rust_crates.spec(
# and OS, e.g. i686-unknown-linux-gnu also matches the i686-unknown-linux-musl
# platform.
rust_crates.from_specs(
cargo_lockfile = "//crates:Cargo.lock",
lockfile = "//crates:Cargo.Bazel.lock",
supported_platform_triples = [
"aarch64-apple-darwin",
"aarch64-pc-windows-msvc",
Expand All @@ -142,6 +145,20 @@ rust_crates.render_config(
)
use_repo(rust_crates, "crates")

# ===== DEV ONLY DEPS AND SETUP BELOW HERE =====
bazel_dep(name = "sphinxdocs", version = "0.0.0", dev_dependency = True)
local_path_override(
module_name = "sphinxdocs",
path = "sphinxdocs",
)

bazel_dep(name = "rules_bazel_integration_test", version = "0.27.0", dev_dependency = True)
bazel_dep(name = "rules_testing", version = "0.6.0", dev_dependency = True)
bazel_dep(name = "rules_shell", version = "0.3.0", dev_dependency = True)
bazel_dep(name = "rules_multirun", version = "0.9.0", dev_dependency = True)
bazel_dep(name = "bazel_ci_rules", version = "1.0.0", dev_dependency = True)
bazel_dep(name = "rules_pkg", version = "1.2.0", dev_dependency = True)

# Rust toolchains to cross-compile the release artifacts for other Linux CPUs
# from Linux x86_64; see dev/release_artifacts. They target musl, which Rust can
# link statically with its bundled rust-lld, so no C cross toolchain is needed.
Expand Down Expand Up @@ -261,12 +278,6 @@ rust.repository_set(
target_triple = "aarch64-pc-windows-msvc",
)

# Use the Rust-based build tools when developing rules_python itself.
register_toolchains(
"//dev/dev_only_toolchains:exe_zip_maker_toolchain",
dev_dependency = True,
)

bazel_dep(name = "other", version = "0", dev_dependency = True)
bazel_dep(name = "another_module", version = "0", dev_dependency = True)

Expand Down
Loading
Loading