From ae445d4e4f2434d9a64ce38caab1f6fa086df02e Mon Sep 17 00:00:00 2001 From: betaboon Date: Sat, 18 May 2024 18:40:43 +0200 Subject: [PATCH] refactor(bzlmod): mark lock_import and lock_repos as reproducible --- MODULE.bazel | 2 +- pycross/private/bzlmod/BUILD.bazel | 2 ++ pycross/private/bzlmod/lock_import.bzl | 5 +++++ pycross/private/bzlmod/lock_repos.bzl | 5 +++++ 4 files changed, 13 insertions(+), 1 deletion(-) 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..dda1515 100644 --- a/pycross/private/bzlmod/BUILD.bazel +++ b/pycross/private/bzlmod/BUILD.bazel @@ -35,6 +35,7 @@ bzl_library( "//pycross/private:poetry_lock_model", "//pycross/private:pypi_file", "//pycross/private:resolved_lock_repo", + "@bazel_features//:features", ] + REPO_HTTP_DEPS, ) @@ -61,6 +62,7 @@ bzl_library( ":tag_attrs", "//pycross/private:package_repo", "//pycross/private:pypi_file", + "@bazel_features//:features", "@lock_import_repos_hub//:locks.bzl", ] + REPO_HTTP_DEPS, ) 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.",