Py_binary implementation requires changes #345
Comments
I'll let the owners chime in, but I believe this is working as intended. Although I won't make a claim about their hermeticity. |
I don't exactly disagree with you, but that's not really actionable feedback.
There is some odd behaviour in Here's an example load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
load("@io_bazel_rules_docker//container:container.bzl", "container_image", "container_push")
load("@pypi//:requirements.bzl", "requirement")
py_binary(
name = "producer",
srcs = glob(["*.py"]),
deps = [
requirement("boto3"),
requirement("click"),
requirement("goodreads"),
requirement("loguru"),
],
python_version = "PY3",
)
py_test(
name = "goodreads_data_collector_test",
srcs = ["goodreads_data_collector_test.py"),
deps = [
":producer",
],
size="small",
)
filegroup(
name = "producer_zip",
srcs= [":producer"],
output_group = "python_zip_file",
)
container_image(
name = "image",
base = "@python_base//image",
files = [
":producer_zip",
],
entrypoint = [
"python3",
"producer.zip",
],
cmd = []
)
container_push(
name = "push_image",
image = ":image",
format = "Docker",
registry = "index.docker.io",
# NOTE: The repository must already exist, and when executing this rule can hang for a while not outputting anything.
# Expect to wait up to 10 minutes on slower internet connections.
repository = "thundergolfer/workflows-and-pipelines-producer",
tag = "dev", # NOTE: Don't do this for non-demo stuff. Stick to immutable tagging/SHA256
tags = [
"docker_image",
]
)
Regarding "Describe the solution you'd like", we you say "py binary rule first download the python source," do you mean that |
Lets say I have created rest.py file. and bazel rule that represent that is rest. When I copy it to container, I have noticed two files files, rest and rest.py.
Also, problem with above example is binary developed and shipped from a python version which may be different from container version. I know we have recently get rid of python 2 completely. |
Yes you can't simply copying the files into a container and have it work.
Yes this is something to watch out for. Are you using |
(Also @systemlogic you've posted the same comment I think 15-20 times. Can you remove the duplicates?) |
@thundergolfer This is what I did with my earlier employer. Since I have moved to a different organization. I thought the idea should be implemented by Bazel. The option should be given in the WORKSPACE file to use custom jfrog aritfactory pypi location. |
@thundergolfer I am talking about something like |
Python binaries are not hermatic
Relevant Rules
python_binary need to be rewritten. I need to install pip packages when I have trying to ship it to the container. Copy of python_binary to any external environment or container should be self-executable,
Description
Current feature force user to install all dependencies in the external environment.
Describe the solution you'd like
py binary rule first download the python source,
compile the it to python package.
pip packages specified in py_library or py_binary rule should go to its sandbox,
copy of py_binary should dump complete environment that includes, python + pip +python source file.
Describe alternatives you've considered
The text was updated successfully, but these errors were encountered: