From 592dc89bb0a5c90089aaf70aa1729b7280547c34 Mon Sep 17 00:00:00 2001 From: betaboon Date: Sat, 18 May 2024 18:40:43 +0200 Subject: [PATCH] feat(bzlmod): mark lock_import and lock_repos as reproducible --- MODULE.bazel | 2 +- pycross/private/bzlmod/BUILD.bazel | 12 ++++++++++-- pycross/private/bzlmod/lock_import.bzl | 5 +++++ pycross/private/bzlmod/lock_repos.bzl | 5 +++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 9439fcc..e300029 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -7,7 +7,7 @@ module( ) bazel_dep(name = "aspect_bazel_lib", version = "1.38.1") -bazel_dep(name = "bazel_features", version = "1.1.1") +bazel_dep(name = "bazel_features", version = "1.11.0") bazel_dep(name = "bazel_skylib", version = "1.4.2") bazel_dep(name = "platforms", version = "0.0.4") bazel_dep(name = "rules_python", version = "0.29.0") diff --git a/pycross/private/bzlmod/BUILD.bazel b/pycross/private/bzlmod/BUILD.bazel index faa679d..29aeb37 100644 --- a/pycross/private/bzlmod/BUILD.bazel +++ b/pycross/private/bzlmod/BUILD.bazel @@ -26,7 +26,11 @@ bzl_library( bzl_library( name = "lock_import", - srcs = ["lock_import.bzl"], + srcs = [ + "lock_import.bzl", + # bazel_features does not provide bzl_library targets. + "@bazel_features//:bzl_files", + ], deps = [ ":lock_hub_repo", ":tag_attrs", @@ -56,7 +60,11 @@ bzl_library( bzl_library( name = "lock_repos", - srcs = ["lock_repos.bzl"], + srcs = [ + "lock_repos.bzl", + # bazel_features does not provide bzl_library targets. + "@bazel_features//:bzl_files", + ], deps = [ ":tag_attrs", "//pycross/private:package_repo", diff --git a/pycross/private/bzlmod/lock_import.bzl b/pycross/private/bzlmod/lock_import.bzl index dee460b..d79dc8f 100644 --- a/pycross/private/bzlmod/lock_import.bzl +++ b/pycross/private/bzlmod/lock_import.bzl @@ -1,5 +1,6 @@ """The lock_import extension.""" +load("@bazel_features//:features.bzl", "bazel_features") load("//pycross/private:lock_attrs.bzl", "package_annotation") load("//pycross/private:pdm_lock_model.bzl", "lock_repo_model_pdm") load("//pycross/private:poetry_lock_model.bzl", "lock_repo_model_poetry") @@ -128,6 +129,10 @@ def _lock_import_impl(module_ctx): repo_files = resolved_lock_files, ) + if bazel_features.external_deps.extension_metadata_has_reproducible: + return module_ctx.extension_metadata(reproducible = True) + return module_ctx.extension_metadata() + # Tag classes _import_pdm_tag = tag_class( doc = "Import a PDM lock file.", diff --git a/pycross/private/bzlmod/lock_repos.bzl b/pycross/private/bzlmod/lock_repos.bzl index aa1aae8..58312fb 100644 --- a/pycross/private/bzlmod/lock_repos.bzl +++ b/pycross/private/bzlmod/lock_repos.bzl @@ -1,5 +1,6 @@ """The lock_repos extension.""" +load("@bazel_features//:features.bzl", "bazel_features") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") load("@lock_import_repos_hub//:locks.bzl", lock_import_locks = "locks") load("//pycross/private:package_repo.bzl", "package_repo") @@ -82,6 +83,10 @@ def _lock_repos_impl(module_ctx): repo_map = repo_remote_files, ) + if bazel_features.external_deps.extension_metadata_has_reproducible: + return module_ctx.extension_metadata(reproducible = True) + return module_ctx.extension_metadata() + # Tag classes _create_tag = tag_class( doc = "Create declared Pycross repos.",