name – (Name) A unique name for this target. mandatory
abi_flags – (str) (default “”) The runtime’s ABI flags, i.e. sys.abiflags. If not set, then it will be set based on flags. optional
bootstrap_template – (label) (default “@rules_python//python/private:bootstrap_template”) The bootstrap script template file to use. Should have %python_binary%, This template, after expansion, becomes the executable file used to start the process, so it is responsible for initial bootstrapping actions such as finding the Python interpreter, runfiles, and constructing an environment to run the intended Python application. While this attribute is currently optional, it will become required when the Python rules are moved out of Bazel itself. The exact variable names expanded is an unstable API and is subject to change. The API will become more stable when the Python rules are moved out of Bazel itself. See @bazel_tools//tools/python:python_bootstrap_template.txt for more variables. optional
coverage_tool – (label) (default None) This is a target to use for collecting code coverage information frompy_binary and py_test targets. If set, the target must either produce a single file or be an executable target. The path to the single file, or the executable if the target is executable, determines the entry point for the python coverage tool. The target and its runfiles will be added to the runfiles when coverage is enabled. The entry point for the tool must be loadable by a Python interpreter (e.g. a.py or .pyc file). It must accept the command line arguments of coverage.py, at least including the run and lcov subcommands. optional
files – (list[label]) (default []) For an in-build runtime, this is the set of files comprising this runtime. These files will be added to the runfiles of Python binaries that use this runtime. For a platform runtime this attribute must not be set. optional
implementation_name – (str) (default “cpython”) The Python implementation name (sys.implementation.name) optional
interpreter – (label) (default None) For an in-build runtime, this is the target to invoke as the interpreter. It can be either of:
A single file, which will be the interpreter binary. It’s assumed such interpreters are either self-contained single-file executables or any supporting files are specified in files.
An executable target. The target’s executable will be the interpreter binary. Any other default outputs (target.files) and plain files runfiles (runfiles.files) will be automatically included as if specified in thefiles attribute. NOTE: the runfiles of the target may not yet be properly respected/propagated to consumers of the toolchain/interpreter, see bazel-contrib/rules_python/issues/1612 For a platform runtime (i.e. interpreter_path being set) this attribute must not be set. optional
interpreter_path – (str) (default “”) For a platform runtime, this is the absolute path of a Python interpreter on the target platform. For an in-build runtime this attribute must not be set. optional
interpreter_version_info – (dict[str, _str_]) (default {}) Version information about the interpreter this runtime provides. If not specified, uses --python_version The supported keys match the names for sys.version_info. While the input values are strings, most are converted to ints. The supported keys are:
major: int, the major version number
minor: int, the minor version number
micro: optional int, the micro version number
releaselevel: optional str, the release level
serial: optional int, the serial number of the release Changed in version 0.36.0: --python_version determines the default value. optional
pyc_tag – (str) (default “”) Optional string; the tag portion of a pyc filename, e.g. the cpython-39 infix of foo.cpython-39.pyc. See PEP 3147. If not specified, it will be computed from implementation_name and interpreter_version_info. If no pyc_tag is available, then only source-less pyc generation will function correctly. optional
python_version – (str) (default “PY3”) Whether this runtime is for Python major version 2 or 3. Valid values are "PY2"and "PY3". The default value is controlled by the --incompatible_py3_is_default flag. However, in the future this attribute will be mandatory and have no default value. optional
site_init_template – (label) (default “@rules_python//python/private:site_init_template”) The template to use for the binary-specific site-init hook run by the interpreter at startup. Added in version 0.41.0. optional
stage2_bootstrap_template – (label) (default “@rules_python//python/private:stage2_bootstrap_template”) The template to use when two stage bootstrapping is enabled optional
zip_main_template – (label) (default “@rules_python//python/private:zip_main_template”) The template to use for a zip’s top-level __main__.py file. This becomes the entry point executed when python foo.zip is run. optional