Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: py_image_layers #349

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

feat: py_image_layers #349

wants to merge 2 commits into from

Conversation

alexeagle
Copy link
Member

Fixes #212


Changes are visible to end-users: yes

  • Searched for relevant documentation and updated as needed: yes
  • Breaking change (forces users to change their own code or config): kind of - needs bazel_lib 2.x
  • Suggested release notes appear below: yes

A helper function to create image layers for a py_binary is now included.

Test plan

  • New test cases added

Copy link
Member

@thesayyn thesayyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@mattem
Copy link
Member

mattem commented Jun 17, 2024

Please provide a description of the change rather than just a link to an issue.

Copy link
Member

@mattem mattem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is becoming public API, please add tests.

# match *only* external pip like repositories that contain the string "site-packages"
SITE_PACKAGES_REGEX = "\\.runfiles/.*/site-packages/.*"

def py_image_layers(name, binary, interpreter_regex = PY_INTERPRETER_REGEX, site_packages_regex = SITE_PACKAGES_REGEX):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pass kwargs and propagate the well known tags.

name = "say_image",
base = "@ubuntu",
entrypoint = ["/examples/py_binary/say_hello"],
tars = py_image_layers("say_image_layers", "say_hello"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this instead produce a filegroup, so it can be used like a regular rule, rather than unexpectedly returning a list?


register_coreutils_toolchains()

register_tar_toolchains()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Users will also need this toolchain? Is the expectation that they register too, or should this ruleset be doing that in the setup

mtree = "{}.{}_tar_manifest".format(name, layer),
)

return result
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

native.filegroup(
    name = name,
    srcs = results,
    ... tags, visibility, etc.
)

# match *only* external pip like repositories that contain the string "site-packages"
SITE_PACKAGES_REGEX = "\\.runfiles/.*/site-packages/.*"

def py_image_layers(name, binary, interpreter_regex = PY_INTERPRETER_REGEX, site_packages_regex = SITE_PACKAGES_REGEX):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interpreter_regex and site_packages_regex are unused, the constants are used in the macro below, did you mean to use them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FR]: py_image_layer
3 participants