Skip to content

Commit 43a32a3

Browse files
authored
refactor: Address a few improvements on uv toolchain (#2062)
Follows: #1989 Addresses the following: * Removes usage of `maybe` * Pretty-print renders some generated *.bazel * Shorter default_repo_names
1 parent eeb7494 commit 43a32a3

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

python/uv/private/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ bzl_library(
3636
name = "toolchains_repo",
3737
srcs = ["toolchains_repo.bzl"],
3838
visibility = ["//python/uv:__subpackages__"],
39+
deps = [
40+
"//python/private:text_util_bzl",
41+
],
3942
)
4043

4144
bzl_library(

python/uv/private/toolchains_repo.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
"Creates a repository to hold toolchains"
1616

17+
load("//python/private:text_util.bzl", "render")
18+
1719
_TOOLCHAIN_TEMPLATE = """
1820
toolchain(
1921
name = "{name}",
@@ -33,7 +35,7 @@ def _toolchains_repo_impl(repository_ctx):
3335
name = toolchain_name,
3436
toolchain_type = repository_ctx.attr.toolchain_type,
3537
toolchain_label = toolchain_label,
36-
compatible_with = json.encode(toolchain_compatible_with),
38+
compatible_with = render.list(toolchain_compatible_with),
3739
)
3840

3941
repository_ctx.file("BUILD.bazel", build_content)

python/uv/private/versions.bzl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,49 +16,49 @@
1616

1717
UV_PLATFORMS = {
1818
"aarch64-apple-darwin": struct(
19-
default_repo_name = "rules_python_uv_darwin_aarch64",
19+
default_repo_name = "uv_darwin_aarch64",
2020
compatible_with = [
2121
"@platforms//os:macos",
2222
"@platforms//cpu:aarch64",
2323
],
2424
),
2525
"aarch64-unknown-linux-gnu": struct(
26-
default_repo_name = "rules_python_uv_linux_aarch64",
26+
default_repo_name = "uv_linux_aarch64",
2727
compatible_with = [
2828
"@platforms//os:linux",
2929
"@platforms//cpu:aarch64",
3030
],
3131
),
3232
"powerpc64le-unknown-linux-gnu": struct(
33-
default_repo_name = "rules_python_uv_linux_ppc",
33+
default_repo_name = "uv_linux_ppc",
3434
compatible_with = [
3535
"@platforms//os:linux",
3636
"@platforms//cpu:ppc",
3737
],
3838
),
3939
"s390x-unknown-linux-gnu": struct(
40-
default_repo_name = "rules_python_uv_linux_s390x",
40+
default_repo_name = "uv_linux_s390x",
4141
compatible_with = [
4242
"@platforms//os:linux",
4343
"@platforms//cpu:s390x",
4444
],
4545
),
4646
"x86_64-apple-darwin": struct(
47-
default_repo_name = "rules_python_uv_darwin_x86_64",
47+
default_repo_name = "uv_darwin_x86_64",
4848
compatible_with = [
4949
"@platforms//os:macos",
5050
"@platforms//cpu:x86_64",
5151
],
5252
),
5353
"x86_64-pc-windows-msvc": struct(
54-
default_repo_name = "rules_python_uv_windows_x86_64",
54+
default_repo_name = "uv_windows_x86_64",
5555
compatible_with = [
5656
"@platforms//os:windows",
5757
"@platforms//cpu:x86_64",
5858
],
5959
),
6060
"x86_64-unknown-linux-gnu": struct(
61-
default_repo_name = "rules_python_uv_linux_x86_64",
61+
default_repo_name = "uv_linux_x86_64",
6262
compatible_with = [
6363
"@platforms//os:linux",
6464
"@platforms//cpu:x86_64",

python/uv/repositories.bzl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ EXPERIMENTAL: This is experimental and may be removed without notice
1818
Create repositories for uv toolchain dependencies
1919
"""
2020

21-
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
2221
load("//python/uv/private:toolchain_types.bzl", "UV_TOOLCHAIN_TYPE")
2322
load("//python/uv/private:toolchains_repo.bzl", "uv_toolchains_repo")
2423
load("//python/uv/private:versions.bzl", "UV_PLATFORMS", "UV_TOOL_VERSIONS")
@@ -98,8 +97,7 @@ def uv_register_toolchains(uv_version = None, register_toolchains = True):
9897
for platform in UV_PLATFORMS.keys():
9998
uv_repository_name = UV_PLATFORMS[platform].default_repo_name
10099

101-
maybe(
102-
uv_repository,
100+
uv_repository(
103101
name = uv_repository_name,
104102
uv_version = uv_version,
105103
platform = platform,

0 commit comments

Comments
 (0)