//python/private/zipapp:py_zipapp_rule.bzl
Implementation of the zipapp rules.
- rule py_zipapp_binary(name, binary, compression='', config_settings={}, executable=True)
Packages a
py_binaryas a Python zipapp.Output groups:
python_zip_file: (deprecated) The plain, non-self-executable zipapp zipfile. This output group is deprecated and retained for compatibility with the previous implicit zipapp functionality. Setexecutable=Falseand use the default output of the target instead.
Added in version 1.9.0.
- Attributes:
A unique name for this target.
mandatory
A
py_binaryorpy_test(or equivalent) target to package.mandatory
Required providers: [
PyExecutableInfo,PyRuntimeInfo]compression– (str) (default “”)The compression level to use.
Typically 0 to 9, with higher numbers being to compress more.
optional
config_settings– (dict[label,str]) (default {})Config settings to change for this target.
The keys are labels for settings, and the values are strings for the new value to use. Pass
Labelobjects or canonical label strings for the keys to ensure they resolve as expected (canonical labels start with@@and can be obtained by callingstr(Label(...))).Most
@rules_python//python/config_settingsettings can be used here, which allows, for example, making only a certainpy_binaryuse--bootstrap_impl=script.Additional or custom config settings can be registered using the
add_transition_settingAPI. This allows, for example, forcing a particular CPU, or defining a custom setting thatselect()uses elsewhere to pick betweenpip.parsehubs. See the [How to guide on multiple versions of a library] for a more concrete example.Note
These values are transitioned on, so will affect the analysis graph and the associated memory overhead. The more unique configurations in your overall build, the more memory and (often unnecessary) re-analysis and re-building can occur. See https://bazel.build/extending/config#memory-performance-considerations for more information about risks and considerations.
optional
executable– (bool) (default True)Whether the output should be an executable zip file.
optional
- rule py_zipapp_test(name, binary, compression='', config_settings={}, executable=True)
Packages a
py_testas a Python zipapp.This target is also a valid test target to run.
Output groups:
python_zip_file: (deprecated) The plain, non-self-executable zipapp zipfile. This output group is deprecated and retained for compatibility with the previous implicit zipapp functionality. Setexecutable=Falseand use the default output of the target instead.
Added in version 1.9.0.
- Attributes:
A unique name for this target.
mandatory
A
py_binaryorpy_test(or equivalent) target to package.mandatory
Required providers: [
PyExecutableInfo,PyRuntimeInfo]compression– (str) (default “”)The compression level to use.
Typically 0 to 9, with higher numbers being to compress more.
optional
config_settings– (dict[label,str]) (default {})Config settings to change for this target.
The keys are labels for settings, and the values are strings for the new value to use. Pass
Labelobjects or canonical label strings for the keys to ensure they resolve as expected (canonical labels start with@@and can be obtained by callingstr(Label(...))).Most
@rules_python//python/config_settingsettings can be used here, which allows, for example, making only a certainpy_binaryuse--bootstrap_impl=script.Additional or custom config settings can be registered using the
add_transition_settingAPI. This allows, for example, forcing a particular CPU, or defining a custom setting thatselect()uses elsewhere to pick betweenpip.parsehubs. See the [How to guide on multiple versions of a library] for a more concrete example.Note
These values are transitioned on, so will affect the analysis graph and the associated memory overhead. The more unique configurations in your overall build, the more memory and (often unnecessary) re-analysis and re-building can occur. See https://bazel.build/extending/config#memory-performance-considerations for more information about risks and considerations.
optional
executable– (bool) (default True)Whether the output should be an executable zip file.
optional