pex_binary
A Python target that can be converted into an executable PEX file.
PEX files are self-contained executable files that contain a complete Python environment capable of running the target. For more information, see https://www.pantsbuild.org/2.21/docs/python/overview/pex.
Backend: pants.backend.python
args
Iterable[str] | None
None
Freeze these command-line args into the PEX. Allows you to run generic entry points on specific arguments without creating a shim file.
This is different to extra_build_args
: args
records arguments used by the packaged PEX when executed, extra_build_args
passes arguments to the process that does the packaging.
check
'error' | 'none' | 'warn' | None
'warn'
Check that the built PEX is valid. Currently this only applies to --layout zipapp
where the PEX zip is tested for importability of its __main__
module by the Python zipimport module. This check will fail for PEX zips that use ZIP64 extensions since the Python zipimport zipimporter only works with 32 bit zips. The check no-ops for all other layouts.
complete_platforms
Iterable[str] | None
None
The platforms the built PEX should be compatible with.
There must be built wheels available for all of the foreign platforms, rather than sdists.
You can give a list of multiple complete platforms to create a multiplatform PEX, meaning that the PEX will be executable in all of the supported environments.
Complete platforms should be addresses of file
targets that point to files that contain complete platform JSON as described by Pex (https://pex.readthedocs.io/en/latest/buildingpex.html#complete-platform).
See https://www.pantsbuild.org/2.21/docs/python/overview/pex for details.
dependencies
Iterable[str] | None
None
Addresses to other targets that this target depends on, e.g. ['helloworld/subdir:lib', 'helloworld/main.py:lib', '3rdparty:reqs#django']
.
This augments any dependencies inferred by Pants, such as by analyzing your imports. Use pants dependencies
or pants peek
on this target to get the final result.
See https://www.pantsbuild.org/2.21/docs/using-pants/key-concepts/targets-and-build-files for more about how addresses are formed, including for generated targets. You can also run pants list ::
to find all addresses in your project, or pants list dir
to find all addresses defined in that directory.
If the target is in the same BUILD file, you can leave off the BUILD file path, e.g. :tgt
instead of helloworld/subdir:tgt
. For generated first-party addresses, use ./
for the file path, e.g. ./main.py:tgt
; for all other generated targets, use :tgt#generated_name
.
You may exclude dependencies by prefixing with !
, e.g. ['!helloworld/subdir:lib', '!./sibling.txt']
. Ignores are intended for false positives with dependency inference; otherwise, simply leave off the dependency from the BUILD file.
description
str | None
None
A human-readable description of the target.
Use pants list --documented ::
to see all targets with descriptions.
emit_warnings
bool | None
None
Whether or not to emit PEX warnings at runtime.
The default is determined by the option emit_warnings
in the [pex-binary-defaults]
scope.
entry_point
str | None
None
Set the entry point, i.e. what gets run when executing ./my_app.pex
, to a module.
You can specify a full module like 'path.to.module'
and 'path.to.module:func'
, or use a shorthand to specify a file name, using the same syntax as the sources
field:
'app.py'
, Pants will convert into the modulepath.to.app
;'app.py:func'
, Pants will convert intopath.to.app:func
.
You may only set one of: this field, or the script
field, or the executable
field. Leave off all three fields to have no entry point.
env
Dict[str, str] | None
None
Freeze these environment variables into the PEX. Allows you to run generic entry points on a specific environment without creating a shim file.