Skip to content

Commit

Permalink
fix: fix py3_image problems
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn committed Oct 4, 2024
1 parent 16ab53a commit 2dd1dbb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions {{ .ProjectSnake }}/.aspect/cli/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ configure:
{{- if and .Computed.go .Scaffold.oci }}
- .aspect/cli/go_image.star
{{- end }}
{{- if and .Computed.python .Scaffold.oci }}
- .aspect/cli/py3_image.star
{{- end }}


{{- if .Scaffold.lint }}
Expand Down
7 changes: 4 additions & 3 deletions {{ .ProjectSnake }}/.aspect/cli/py3_image.star
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
"Generate py_pytest_main targets"
aspect.register_rule_kind("py3_image", {
"From": "//tools/oci:py3_image.bzl",
"ResolveAttrs": ["deps"],
"ResolveAttrs": ["binary"],
})

def declare_targets(ctx):
"""Check for presence of pragma, generate rules if found"""
for file in ctx.sources:
has_pragma = len(file.query_results["pragma"]) > 0
if has_pragma:
py_binary_target_name = path.base(ctx.rel) + "_bin"
ctx.targets.add(
kind = "py3_image",
name = "image",
attrs = {
# TODO: don't hard-code the name
"binary": "app_bin",
"binary": py_binary_target_name
},
)
break

aspect.register_configure_extension(
id = "py3_image",
prepare = lambda cfg: aspect.PrepareResult(
Expand Down
2 changes: 1 addition & 1 deletion {{ .ProjectSnake }}/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ use_repo(oci, "distroless_base", "distroless_base_linux_amd64", "distroless_base
oci.pull(
name = "python_base",
image = "ubuntu",
tag = "latest",
digest = "sha256:b359f1067efa76f37863778f7b6d0e8d911e3ee8efa807ad01fbf5dc1ef9006b",
platforms = [
"linux/arm64/v8",
"linux/amd64",
Expand Down

0 comments on commit 2dd1dbb

Please sign in to comment.