Skip to content

Commit

Permalink
refactor(bzlmod): mark lock_import and lock_repos as reproducible (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
betaboon authored May 28, 2024
1 parent 5ce7a49 commit 531c8d2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
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
2 changes: 2 additions & 0 deletions pycross/private/bzlmod/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand All @@ -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,
)
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 531c8d2

Please sign in to comment.