Create a zip file containing a full Python application.
Follows PEP-441 (PEX)
The resulting zip file does not contain a Python interpreter. Users are expected to execute the PEX with a compatible interpreter on the runtime system.
Use the python_interpreter_constraints
to provide an error if a wrong interpreter tries to execute the PEX, for example:
py_pex_binary(
python_interpreter_constraints = [
"CPython=={major}.{minor}.{patch}",
]
)
py_pex_binary(name, binary, inject_env, python_interpreter_constraints, python_shebang)
Build a pex executable from a py_binary
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
binary | A py_binary target | Label | required | |
inject_env | Environment variables to set when running the pex binary. | Dictionary: String -> String | optional | {} |
python_interpreter_constraints | Python interpreter versions this PEX binary is compatible with. A list of semver strings. The placeholder strings {major} , {minor} , {patch} can be used for gathering version information from the hermetic python toolchain. |
List of strings | optional | ["CPython=={major}.{minor}.*"] |
python_shebang | - | String | optional | "#!/usr/bin/env python3" |