//python/config_settings
- flag --//python/config_settings:python_version
Determines the default hermetic Python toolchain version. This can be set to one of the values that
rules_pythonmaintains.
- flag --//python/config_settings:exec_tools_toolchain
Determines if the
exec_tools_toolchain_typetoolchain is enabled.Note
Note that this only affects the rules_python generated toolchains.
Values:
enabled: Allow matching of the registered toolchains at build time.disabled: Prevent the toolchain from being matched at build time.
Added in version 0.33.2.
- flag --//python/config_settings:precompile
Determines if Python source files should be compiled at build time.
Note
The flag value is overridden by the target level
precompileattribute, except for the case offorce_enabledandforced_disabled.Values:
auto: Automatically decide the effective value based on environment, target platform, etc.enabled: Compile Python source files at build time. Note that--precompile_add_to_runfilesaffects how the compiled files are included into a downstream binary.disabled: Don’t compile Python source files at build time.if_generated_source: Compile Python source files, but only if they’re a generated file.force_enabled: Likeenabled, except overrides target-level setting. This is mostly useful for development, testing enabling precompilation more broadly, or as an escape hatch if build-time compiling is not available.force_disabled: Likedisabled, except overrides target-level setting. This is useful useful for development, testing enabling precompilation more broadly, or as an escape hatch if build-time compiling is not available.
Added in version 0.33.0.
- flag --//python/config_settings:precompile_source_retention
Determines, when a source file is compiled, if the source file is kept in the resulting output or not.
Note
This flag is overridden by the target level
precompile_source_retentionattribute.Values:
keep_source: Include the original Python source.omit_source: Don’t include the orignal py source.omit_if_generated_source: Keep the original source if it’s a regular source file, but omit it if it’s a generated file.
Added in version 0.33.0.
- flag --//python/config_settings:precompile_add_to_runfiles
Determines if a target adds its compiled files to its runfiles.
When a target compiles its files, but doesn’t add them to its own runfiles, it relies on a downstream target to retrieve them from
PyInfo.transitive_pyc_filesValues:
always: Always include the compiled files in the target’s runfiles.decided_elsewhere: Don’t include the compiled files in the target’s runfiles; they are still added toPyInfo.transitive_pyc_files. See also:py_binary.pyc_collectionattribute. This is useful for allowing incrementally enabling precompilation on a per-binary basis.
Added in version 0.33.0.
- flag --//python/config_settings:pyc_collection
Determine if
py_binarycollects transitive pyc files.Note
This flag is overridden by the target level
pyc_collectionattribute.Values:
include_pyc: IncludePyInfo.transitive_pyc_filesas part of the binary.disabled: Don’t includePyInfo.transitive_pyc_filesas part of the binary.
Added in version 0.33.0.
- flag --//python/config_settings:py_linux_libc
Set what libc is used for the target platform. This will affect which whl binaries will be pulled and what toolchain will be auto-detected. Currently
rules_pythononly supplies toolchains compatible withglibc.Values:
glibc: Useglibc, default.muslc: Usemuslc.
Added in version 0.33.0.
- flag --//python/config_settings:pip_whl
Set what distributions are used in the
pipintegration.Values:
auto: Preferwhldistributions if they are compatible with a target platform, but fallback tosdist. This is the default.only: Only usewhldistributions and error out if it is not available.no: Only usesdistdistributions. The wheels will be built non-hermetically in thewhl_libraryrepository rule.
Added in version 0.33.0.
- flag --//python/config_settings:pip_whl_osx_arch
Set what wheel types we should prefer when building on the OSX platform.
Values:
arch: Prefer architecture specific wheels.universal: Prefer universal wheels that usually are bigger and contain binaries for both, Intel and ARM architectures in the same wheel.
Added in version 0.33.0.
- flag --//python/config_settings:pip_whl_glibc_version
Set the minimum
glibcversion that thepy_binaryusingwhldistributions from a PyPI index should support.Values:
"": Select the lowest available version of each wheel giving you the maximum compatibility. This is the default.X.Y: The string representation of aglibcversion. The allowed values depend on therequirements.txtlock file contents.
Added in version 0.33.0.
- flag --//python/config_settings:pip_whl_muslc_version
Set the minimum
muslcversion that thepy_binaryusingwhldistributions from a PyPI index should support.Values:
"": Select the lowest available version of each wheel giving you the maximum compatibility. This is the default.X.Y: The string representation of amuslcversion. The allowed values depend on therequirements.txtlock file contents.
Added in version 0.33.0.
- flag --//python/config_settings:pip_whl_osx_version
Set the minimum
osxversion that thepy_binaryusingwhldistributions from a PyPI index should support.Values:
"": Select the lowest available version of each wheel giving you the maximum compatibility. This is the default.X.Y: The string representation of the MacOS version. The allowed values depend on therequirements.txtlock file contents.
Added in version 0.33.0.
- flag --//python/config_settings:bootstrap_impl
Determine how programs implement their startup process.
Values:
system_python: Use a bootstrap that requires a system Python available in order to start programs. This requiresPyRuntimeInfo.bootstrap_templateto be a Python program.script: Use a bootstrap that uses an arbitrary executable script (usually a shell script) instead of requiring it be a Python program.
Note
The
scriptbootstrap requires the toolchain to provide thePyRuntimeInfoprovider fromrules_python. This loosely translates to using Bazel 7+ with a toolchain created by rules_python. Most notably, WORKSPACE builds default to using a legacy toolchain built into Bazel itself which doesn’t support the script bootstrap. If not available, thesystem_pythonbootstrap will be used instead.Added in version 0.33.0.