Creating a pkg_tar from a py_binary

1,510 views
Skip to first unread message

Ram Kumar Rengaswamy

unread,
Mar 18, 2016, 1:58:13 AM3/18/16
to bazel-discuss
My goal is to create tar ball from the output of a py_binary rule.
The tar ball should include the wrapper script and all the files under the runfiles directory.

I tried to include the py_binary as the files attribute of pkg_tar but that did not work as intended.
The resulting tar ball only had the wrapper script and the main file of the python binary.

What would be the bazel way to create a tar ball of a py_binary rule ?

Thanks,
-Ram

Damien Martin-guillerez

unread,
Mar 18, 2016, 5:59:54 AM3/18/16
to Ram Kumar Rengaswamy, bazel-discuss
I seem to have lost it but I had a version of a skylark rule that was basically collecting the runfiles provider from a py_binary to generate a tar file.

I think it would make sense to add a way to add the whole runfiles tree to a tar file.


--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/592d2ee2-1392-46b2-a1b6-c69f7d6f57ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brian Silverman

unread,
Mar 18, 2016, 11:40:19 AM3/18/16
to Damien Martin-guillerez, Ram Kumar Rengaswamy, bazel-discuss
For py_binary in particular, you also (probably) need the __init__.py files which are separate. Ica2adab481cfecabb84b608cd952b0cae5a8653c exposes that information; anybody available to review it?

Ram Kumar Rengaswamy

unread,
Mar 18, 2016, 11:59:55 AM3/18/16
to bazel-discuss, dmar...@google.com, ra...@beeswax.com
@Damien ... I can write a skylark rule in that case. Just wanted to confirm if it was already supported.

@Brian ... We are currently adding __init__.py files to all our py_library rules. Usually these files are empty but sometimes we have some initialization code in them. Is that the right pattern ? Not sure what you meant by __init__.py files are separate.

Thanks folks.

Brian Silverman

unread,
Mar 18, 2016, 3:37:18 PM3/18/16
to Ram Kumar Rengaswamy, bazel-discuss, Damien Martin-guillerez
Bazel automatically adds empty __init__.py files to the .runfiles directory if you don't do it explicitly. If you want to use those, it's separate from the "normal" runfiles. Adding them explicitly definitely works too though.

Damien Martin-guillerez

unread,
Mar 18, 2016, 4:16:33 PM3/18/16
to Brian Silverman, Ram Kumar Rengaswamy, bazel-discuss
Just saying in passing that I would be happy to review a change to add binaries input to pkg_tar / docker_build, I am just saying in case :)

Kamal Marhubi

unread,
Mar 18, 2016, 7:45:24 PM3/18/16
to Damien Martin-guillerez, Brian Silverman, Ram Kumar Rengaswamy, bazel-discuss
There's an issue tracking runfiles in pkg_tar (and so docker_build): https://github.com/bazelbuild/bazel/issues/671

Reply all
Reply to author
Forward
0 new messages