is the generic entry point for Abseil Python applications. This is a key difference from how python applications are typically run, where you identify a specific file as the entry point, e.g., $ python When you run your application via Bazel, Bazel automatically determines the entry point by searching for within a build rule’s source files.

When the program starts, parses the flags, printing a usage message and failing if illegal flags or flag values are specified.

For example, if you have a file called that calls

from absl import app
from absl import flags


flags.DEFINE_string('name', 'Jane Random', 'Your name.')

def main(argv):
  if FLAGS.debug:
    print('non-flag arguments:', argv)
  print('Happy, ',

if __name__ == '__main__':

and you have a bazel build rule such as:

  name = "hello",
  deps = [],
  srcs = [""],

You could then run your target as follows:

$ bazel run :hello

When using’s run() to start your program, C++ flags will automatically be available.