//python/uv:uv.bzl
EXPERIMENTAL: This is experimental and may be removed without notice.
The uv toolchain extension.
- module ext uv
A module extension for working with uv.
Basic usage:
uv = use_extension( "@rules_python//python/uv:uv.bzl", "uv", # Use `dev_dependency` so that the toolchains are not defined pulled when # your module is used elsewhere. dev_dependency = True, ) uv.configure(version = "0.5.24")
Since this is only for locking the requirements files, it should be always marked as a
dev_dependency.- uv.configure(base_url='', compatible_with=[], manifest_filename='dist-manifest.json', platform='', sha256='', target_settings=[], urls=[], version='')
Build the
uvtoolchain configuration by appending the provided configuration. The information is appended to the version configuration that is specified byversionattribute, or if the version is unspecified, the version of the lastuv.configurecall in the current module, or the version from the defaults is used.Complex configuration example:
# Configure the base_url for the default version. uv.configure(base_url = "my_mirror") # Add an extra platform that can be used with your version. uv.configure( platform = "extra-platform", target_settings = ["//my_config_setting_label"], compatible_with = ["@platforms//os:exotic"], ) # Add an extra platform that can be used with your version. uv.configure( platform = "patched-binary", target_settings = ["//my_super_config_setting"], urls = ["https://example.zip"], sha256 = "deadbeef", )
- Attributes:
Base URL to download metadata about the binaries and the binaries themselves.
optional
compatible_with– (list[label]) (default [])The compatible with constraint values for toolchain resolution.
optional
manifest_filename– (str) (default “dist-manifest.json”)The distribution manifest filename to use for the metadata fetching from GH. The defaults for this are set in
rules_pythonMODULE.bazel file that one can override for a specific version.optional
The platform string used in the UV repository to denote the platform triple.
optional
The sha256 of the downloaded artifact if the
urlsis specified.optional
target_settings– (list[label]) (default [])The
target_settingsto add to platform definitions that then get used intoolchaindefinitions.optional
urls– (list[str]) (default [])The urls to download the binary from. If this is used,
base_urlandmanifest_nameare ignored for the given version.If the
urlsare specified, they need to be specified for all of the platforms for a particular version.optional
The version of uv to configure the sources for. If this is not specified it will be the last version used in the module or the default version set by
rules_python.optional
- uv.default(base_url='', compatible_with=[], manifest_filename='dist-manifest.json', platform='', target_settings=[], version='')
Set the uv configuration defaults.
- Attributes:
Base URL to download metadata about the binaries and the binaries themselves.
optional
compatible_with– (list[label]) (default [])The compatible with constraint values for toolchain resolution.
optional
manifest_filename– (str) (default “dist-manifest.json”)The distribution manifest filename to use for the metadata fetching from GH. The defaults for this are set in
rules_pythonMODULE.bazel file that one can override for a specific version.optional
The platform string used in the UV repository to denote the platform triple.
optional
target_settings– (list[label]) (default [])The
target_settingsto add to platform definitions that then get used intoolchaindefinitions.optional
The version of uv to configure the sources for. If this is not specified it will be the last version used in the module or the default version set by
rules_python.optional