rules
Public API re-exports
Rules
py_binary_rule
Run a Python program under Bazel. Most users should use the py_binary macro instead of loading this directly.
Example usage (generated):
load("@aspect_rules_py//py:defs.bzl", "py_binary_rule")
py_binary_rule(
# A unique name for this target.
name = "",
# Script to execute with the Python interpreter.
main = "",
)
name
Required name.
A unique name for this target.
data
Optional list of labels.
Default: []
Runtime dependencies of the program.
The transitive closure of the data
dependencies will be available in the .runfiles
folder for this binary/test. The program may optionally use the Runfiles lookup library to
locate the data files, see https://pypi.org/project/bazel-runfiles/.
deps
Optional list of labels.
Default: []
[Must provide PyInfo
][Must provide `PyWheelInfo`]
Targets that produce Python code, commonly py_library
rules.
env
Optional dictionary: String → String.
Default: {}
Environment variables to set when running the binary.
imports
Optional list of strings.
Default: []
List of import directories to be added to the PYTHONPATH.
main
Required label.
Script to execute with the Python interpreter.
srcs
Optional list of labels.
Default: []
Python source files.
py_library
Example usage (generated):
load("@aspect_rules_py//py:defs.bzl", "py_library")
py_library(
# A unique name for this target.
name = "",
)
name
Required name.
A unique name for this target.
data
Optional list of labels.
Default: []
Runtime dependencies of the program.
The transitive closure of the data
dependencies will be available in the .runfiles
folder for this binary/test. The program may optionally use the Runfiles lookup library to
locate the data files, see https://pypi.org/project/bazel-runfiles/.
deps
Optional list of labels.
Default: []
[Must provide PyInfo
][Must provide `PyWheelInfo`]
Targets that produce Python code, commonly py_library
rules.
imports
Optional list of strings.
Default: []
List of import directories to be added to the PYTHONPATH.
srcs
Optional list of labels.
Default: []
Python source files.
py_test_rule
Run a Python program under Bazel. Most users should use the py_test macro instead of loading this directly.
Example usage (generated):
load("@aspect_rules_py//py:defs.bzl", "py_test_rule")
py_test_rule(
# A unique name for this target.
name = "",
# Script to execute with the Python interpreter.
main = "",
)
name
Required name.
A unique name for this target.
data
Optional list of labels.
Default: []
Runtime dependencies of the program.
The transitive closure of the data
dependencies will be available in the .runfiles
folder for this binary/test. The program may optionally use the Runfiles lookup library to
locate the data files, see https://pypi.org/project/bazel-runfiles/.
deps
Optional list of labels.
Default: []
[Must provide PyInfo
][Must provide `PyWheelInfo`]
Targets that produce Python code, commonly py_library
rules.
env
Optional dictionary: String → String.
Default: {}
Environment variables to set when running the binary.
imports
Optional list of strings.
Default: []
List of import directories to be added to the PYTHONPATH.
main
Required label.
Script to execute with the Python interpreter.
srcs
Optional list of labels.
Default: []
Python source files.
py_venv
Example usage (generated):
load("@aspect_rules_py//py:defs.bzl", "py_venv")
py_venv(
# A unique name for this target.
name = "",
)
name
Required name.
A unique name for this target.
data
Optional list of labels.
Default: []
Runtime dependencies of the program.
The transitive closure of the data
dependencies will be available in the .runfiles
folder for this binary/test. The program may optionally use the Runfiles lookup library to
locate the data files, see https://pypi.org/project/bazel-runfiles/.
deps
Optional list of labels.
Default: []
[Must provide PyInfo
][Must provide `PyWheelInfo`]
Targets that produce Python code, commonly py_library
rules.
imports
Optional list of strings.
Default: []
List of import directories to be added to the PYTHONPATH.
srcs
Optional list of labels.
Default: []
Python source files.
strip_pth_workspace_root
Optional boolean.
Default: True
py_wheel
Example usage (generated):
load("@aspect_rules_py//py:defs.bzl", "py_wheel")
py_wheel(
# A unique name for this target.
name = "",
)
name
Required name.
A unique name for this target.
src
Optional label.
Default: None
The Wheel file, as defined by https://packaging.python.org/en/latest/specifications/binary-distribution-format/#binary-distribution-format
Macros and Functions
py_binary
Wrapper macro for py_binary_rule
, setting a default for imports.
It also creates a virtualenv to constrain the interpreter and packages used at runtime,
you can bazel run [name].venv
to produce this, then use it in the editor.
Example usage (generated):
load("@aspect_rules_py//py:defs.bzl", "py_binary")
py_binary(
# name of the rule
name = "",
)
name
Required.
name of the rule
srcs
Optional. Default: []
python source files
main
Optional. Default: None
the entry point. If absent, then the first entry in srcs is used.
imports
Optional. Default: ["."]
List of import paths to add for this binary.
kwargs
Optional.
additional named parameters to the py_binary_rule
py_pytest_main
py_pytest_main wraps the template rendering target and the final py_library.
Example usage (generated):
load("@aspect_rules_py//py:defs.bzl", "py_pytest_main")
py_pytest_main(
# The name of the runable target that updates the test entry file.
name = "",
)
name
Required.
The name of the runable target that updates the test entry file.
py_library
Optional. Default: <unknown object com.google.devtools.build.skydoc.fakebuildapi.FakeStarlarkRuleFunctionsApi$RuleDefinitionIdentifier>
Use this attribute to override the default py_library rule.
deps
Optional. Default: []
A list containing the pytest library target, e.g., @pypi_pytest//:pkg.
data
Optional. Default: []
A list of data dependencies to pass to the py_library target.
testonly
Optional. Default: True
A boolean indicating if the py_library target is testonly.
kwargs
Optional.
The extra arguments passed to the template rendering target.
py_test
Identical to py_binary, but produces a target that can be used with bazel test
.
Example usage (generated):
load("@aspect_rules_py//py:defs.bzl", "py_test")
py_test(
name = "",
)
name
Required.
main
Optional. Default: None
srcs
Optional. Default: []
imports
Optional. Default: ["."]
kwargs
Optional.