Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify "--build_python_zip" flag within Bazel py_binary rule

Tags:

bazel

Is it possible to specify the bazel "--build_python_zip" flag from within the py_binary rule so that I don't need to add this flag every time I use Bazel in my workspace?

like image 498
Marco Antonio Ximenes Rego Mon Avatar asked Oct 17 '25 22:10

Marco Antonio Ximenes Rego Mon


1 Answers

After PR 9453, you can:

filegroup(
    name = "foo_zip",
    srcs = [":foo_binary"],
    output_group = "python_zip_file",
)

py_binary(
    name = "foo_binary",
    srcs = ["foo.py"],
)

Then you can invoke bazel as:

bazel build :foo_zip

and don't have to specify --build_python_zip. This will also allow par_binary rules to co-exist with native zips.

like image 65
Shashank Bharadwaj Avatar answered Oct 22 '25 04:10

Shashank Bharadwaj