//python/config_settings — rules_python 0.0.0 documentation (original) (raw)

flag --//python/config_settings:add_srcs_to_runfiles

Determines if the srcs of targets are added to their runfiles.

More specifically, the sources added to runfiles are the .py files in srcs. If precompiling is performed, it is the .py files that are kept according to precompile_source_retention.

Values:

Added in version 0.37.0.

Deprecated since version 0.37.0: This is a transition flag and will be removed in a subsequent release.

flag --//python/config_settings:python_version

Determines the default hermetic Python toolchain version. This can be set to one of the values that rules_python maintains.

//python/config_settings:python_version_major_minor

Parses the value of the python_version and transforms it into a X.Y value.

//python/config_settings:is_python_*

config_settings to match Python versions

The name pattern is is_python_X.Y (to match major.minor) and is_python_X.Y.Z(to match major.minor.patch).

Note that the set of available targets depends on the configuredTOOL_VERSIONS. Versions may not always be available if the root module has customized them, or as older Python versions are removed from rules_python’s set of builtin, known versions.

If you need to match a version that isn’t present, then you have two options:

  1. Manually define a config_setting and have it match --python_versionor python_version_major_minor. This works best when you don’t control the root module, or don’t want to rely on the MODULE.bazel configuration. Such a config settings would look like:

Match any 3.5 version

config_setting(
name = "is_python_3.5",
flag_values = {
"@rules_python//python/config_settings:python_version_major_minor": "3.5",
}
)

Match exactly 3.5.1

config_setting(
name = "is_python_3.5.1",
flag_values = {
"@rules_python//python/config_settings:python_version": "3.5.1",
}
) 2. Use python.single_override to re-introduce the desired version so that the corresponding //python/config_setting:is_python_XXX target is generated.

flag --//python/config_settings:exec_tools_toolchain

Determines if the exec_tools_toolchain_type toolchain is enabled.

Note

Values:

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 precompile attribute, except for the case of force_enabled and forced_disabled.

Values:

Added in version 0.33.0.

Changed in version 0.37.0: The if_generated_source value was removed

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:

Added in version 0.33.0.

Added in version 0.36.0: The auto value

Changed in version 0.37.0: The omit_if_generated_source value was removed

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_python only supplies toolchains compatible with glibc.

Values:

Added in version 0.33.0.

flag --//python/config_settings:py_freethreaded

Set whether to use an interpreter with the experimental freethreaded option set to true.

Values:

Added in version 0.38.0.

flag --//python/config_settings:pip_whl

Set what distributions are used in the pip integration.

Values:

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:

Added in version 0.33.0.

flag --//python/config_settings:pip_whl_glibc_version

Set the minimum glibc version that the py_binary using whl distributions from a PyPI index should support.

Values:

Added in version 0.33.0.

flag --//python/config_settings:pip_whl_muslc_version

Set the minimum muslc version that the py_binary using whl distributions from a PyPI index should support.

Values:

Added in version 0.33.0.

flag --//python/config_settings:pip_whl_osx_version

Set the minimum osx version that the py_binary using whl distributions from a PyPI index should support.

Values:

Added in version 0.33.0.

flag --//python/config_settings:venvs_site_packages

Determines if libraries use a site-packages layout for their files.

Note this flag only affects PyPI dependencies of --bootstrap_impl=script binaries

Warning

Experimental API. This API is still under development and may change or be removed without notice.

Values:

flag --//python/config_settings:bootstrap_impl

Determine how programs implement their startup process.

Values:

Note

The script bootstrap requires the toolchain to provide the PyRuntimeInfoprovider from rules_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, the system_python bootstrap will be used instead.

Added in version 0.33.0.

flag --//python/config_settings:current_config

Fail the build if the current build configuration does not match thepip.parse defined wheels.

Values:

Added in version 1.1.0.

flag --//python/config_settings:venvs_use_declare_symlink

Determines if relative symlinks are created using declare_symlink() at build time.

This is only intended to work around#2489, where some packaging rules don’t support declare_symlink() artifacts.

Values:

Added in version 1.2.0.