bazel action to invoke py_binary

165 views
Skip to first unread message

Uma Patil

unread,
Sep 23, 2022, 3:21:48 PM9/23/22
to bazel-discuss
Hi ,

I have a python program that takes 2 command line arguments and execute the logic to do desired action. And I'm generating a executable by using py_binary for python program.  I want to have a bazel rule to invoke the py_binary and pass 2 command line arguments to that rule by calling it from where ever I want. 

//example/Build   : py_binary:
py_binary(
  name = "py_pgm",
  srcs = glob(["*.py"]),
  main = "main.py",
  visibility = ["//visibility:public"],
)

examples/defs.bzl:
def _impl(ctx): 
           ctx.action( 
                             ) 
ex_rule= rule( 
            implementation = _impl, 
             attrs = {  } )

I need a rule to invoke the "example"

application/Build:
load('//examples:defs.bzl', 'ex_rule')

ex_rule(
     name:run
     args = device_name and file path
)

Can someone help me with the bazel rule to invoke py_binary. I looked online for some hints but the ones present are from 2016 and many of the logics are deprecated so I couldn't get anything to work.
Referred Sources:

If someone can help me with the rule it would be of great help.

Thank you in advance,
Uma
Reply all
Reply to author
Forward
0 new messages