Public API re-exports
py_binary_rule(name, data, deps, env, imports, main, resolutions, srcs)
Run a Python program under Bazel. Most users should use the py_binary macro instead of loading this directly.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
data | 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/. |
List of labels | optional | [] |
deps | Targets that produce Python code, commonly py_library rules. |
List of labels | optional | [] |
env | Environment variables to set when running the binary. | Dictionary: String -> String | optional | {} |
imports | List of import directories to be added to the PYTHONPATH. | List of strings | optional | [] |
main | Script to execute with the Python interpreter. | Label | required | |
resolutions | FIXME | Dictionary: Label -> String | optional | {} |
srcs | Python source files. | List of labels | optional | [] |
py_library_rule(name, data, deps, imports, resolutions, srcs, virtual_deps)
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
data | 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/. |
List of labels | optional | [] |
deps | Targets that produce Python code, commonly py_library rules. |
List of labels | optional | [] |
imports | List of import directories to be added to the PYTHONPATH. | List of strings | optional | [] |
resolutions | FIXME | Dictionary: Label -> String | optional | {} |
srcs | Python source files. | List of labels | optional | [] |
virtual_deps | - | List of strings | optional | [] |
py_test_rule(name, data, deps, env, imports, main, resolutions, srcs)
Run a Python program under Bazel. Most users should use the py_test macro instead of loading this directly.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
data | 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/. |
List of labels | optional | [] |
deps | Targets that produce Python code, commonly py_library rules. |
List of labels | optional | [] |
env | Environment variables to set when running the binary. | Dictionary: String -> String | optional | {} |
imports | List of import directories to be added to the PYTHONPATH. | List of strings | optional | [] |
main | Script to execute with the Python interpreter. | Label | required | |
resolutions | FIXME | Dictionary: Label -> String | optional | {} |
srcs | Python source files. | List of labels | optional | [] |
py_unpacked_wheel_rule(name, py_package_name, src)
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
py_package_name | - | String | required | |
src | The Wheel file, as defined by https://packaging.python.org/en/latest/specifications/binary-distribution-format/#binary-distribution-format | Label | required |
py_binary(name, srcs, main, imports, kwargs)
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.
PARAMETERS
py_library(name, imports, kwargs)
Wrapper macro for the py_library_rule, supporting virtual deps.
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | Name for this rule. | none |
imports | List of import paths to add for this library. | ["."] |
kwargs | Additional named parameters to py_library_rule. | none |
py_pytest_main(name, py_library, deps, data, testonly, kwargs)
py_pytest_main wraps the template rendering target and the final py_library.
PARAMETERS
py_test(name, main, srcs, imports, kwargs)
Identical to py_binary, but produces a target that can be used with bazel test
.
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | - |
none |
main | - |
None |
srcs | - |
[] |
imports | - |
["."] |
kwargs | - |
none |
py_unpacked_wheel(name, kwargs)
Wrapper macro for the py_unpacked_wheel_rule, setting a defaults.
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | Name of this rule. | none |
kwargs | Additional named parameters to py_unpacked_wheel_rule. | none |
py_venv(name, kwargs)
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | - |
none |
kwargs | - |
none |
resolutions.from_requirements(base, requirement_fn)
Returns data representing the resolution for a given set of dependencies
PARAMETERS
RETURNS
A resolution struct for use with virtual deps.
resolutions.empty()