Skip to content

Commit

Permalink
feat(bzlmod): mark lock_import and lock_repos as reproducible
Browse files Browse the repository at this point in the history
  • Loading branch information
betaboon committed May 18, 2024
1 parent 5ce7a49 commit 592dc89
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
12 changes: 10 additions & 2 deletions pycross/private/bzlmod/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions pycross/private/bzlmod/lock_import.bzl
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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.",
Expand Down
5 changes: 5 additions & 0 deletions pycross/private/bzlmod/lock_repos.bzl
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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.",
Expand Down

0 comments on commit 592dc89

Please sign in to comment.