//python:py_exec_tools_info.bzl

Provider for the exec tools toolchain.

See also

providerPyExecToolsInfo

Build tools used as part of building Python programs.

PyExecToolsInfo.<init>(exec_interpreter,precompiler)
PyExecToolsInfo.exec_interpreter:Target|None

If available, an interpreter valid for running in the exec configuration.When running it in an action, useDefaultInfo.files_to_run to ensure all itsfiles are appropriately available. An exec interpreter may not be available,e.g. if all the exec tools are prebuilt binaries.

Note

this interpreter is really only for use when a build tool cannot usethe Python toolchain itself. When possible, prefeer to define apy_binaryinstead and use it via acfg=exec attribute; this makes it much easierto setup the runtime environment for the binary. See also:py_interpreter_program rule.

Note

What interpreter is used depends on the toolchain constraints. Ensure theproper target constraints are being applied when obtaining this from thetoolchain.

Warning

This does not work correctly in case of RBE, please use exec_runtime instead.

Once https://github.com/bazelbuild/bazel/issues/23620 is resolved this warningmay be removed.

PyExecToolsInfo.precompiler:Target|None

If available, the tool to use for generating pyc files. If not available,precompiling will not be available.

Must provide one of the following:

  • PyInterpreterProgramInfo

  • DefaultInfo.files_to_run

This target provides either thePyInterpreterProgramInfo provider or is aregular executable binary (provides DefaultInfo.files_to_run). When thePyInterpreterProgramInfo provider is present, it means the precompiler programdoesn’t know how to find the interpreter itself, so the caller must provide itwhen constructing the action invocation for running the precompiler program(typicallyexec_interpreter). See thePyInterpreterProgramInfo provider docsfor details on how to construct an invocation.

Iftesting.ExecutionInfo is provided, it will be used to set executionrequirements. This can be used to control persistent worker settings.

The precompiler command line API is:

  • --invalidation_mode: The type of pyc invalidation mode to use. Should beone ofunchecked_hash orchecked_hash.

  • --optimize: The optimization level as an integer.

  • --python_version: The Python version, inMajor.Minor format, e.g.3.12

The following args are repeated and form a list of 3-tuples of their values. Atleast one 3-tuple will be passed.

  • --src: Path to the source.py file to precompile.

  • --src_name: The human-friendly file name to record in the pyc output.

  • --pyc: Path to where pyc output should be written.

NOTE: These argumentsmay be stored in a file instead, in which case, thepath to that file will be a positional arg starting with@, e.g.@foo/bar.The format of the file is one arg per line.