• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 24068485941

07 Apr 2026 06:52AM UTC coverage: 75.981% (-16.9%) from 92.908%
24068485941

Pull #23227

github

web-flow
Merge 7f50667e7 into 542ca048d
Pull Request #23227: Fix uv PEX builder to use pex3 lock export

0 of 12 new or added lines in 1 file covered. (0.0%)

11082 existing lines in 400 files now uncovered.

54018 of 71094 relevant lines covered (75.98%)

2.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/src/python/pants/backend/python/subsystems/uv.py
1
# Copyright 2026 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
from __future__ import annotations
5✔
5

6
from dataclasses import dataclass
5✔
7

8
from pants.core.util_rules.external_tool import (
5✔
9
    TemplatedExternalTool,
10
    download_external_tool,
11
)
12
from pants.engine.fs import Digest
5✔
13
from pants.engine.platform import Platform
5✔
14
from pants.engine.rules import collect_rules, rule
5✔
15
from pants.option.option_types import ArgsListOption
5✔
16
from pants.util.strutil import softwrap
5✔
17

18

19
class Uv(TemplatedExternalTool):
5✔
20
    options_scope = "uv"
5✔
21
    name = "uv"
5✔
22
    help = "The uv Python package manager (https://github.com/astral-sh/uv)."
5✔
23

24
    default_version = "0.6.14"
5✔
25
    default_known_versions = [
5✔
26
        "0.6.14|macos_x86_64|1d8ecb2eb3b68fb50e4249dc96ac9d2458dc24068848f04f4c5b42af2fd26552|16276555",
27
        "0.6.14|macos_arm64|4ea4731010fbd1bc8e790e07f199f55a5c7c2c732e9b77f85e302b0bee61b756|15138933",
28
        "0.6.14|linux_x86_64|0cac4df0cb3457b154f2039ae471e89cd4e15f3bd790bbb3cb0b8b40d940b93e|17032361",
29
        "0.6.14|linux_arm64|94e22c4be44d205def456427639ca5ca1c1a9e29acc31808a7b28fdd5dcf7f17|15577079",
30
    ]
31
    version_constraints = ">=0.6.0,<1.0"
5✔
32

33
    default_url_template = (
5✔
34
        "https://github.com/astral-sh/uv/releases/download/{version}/uv-{platform}.tar.gz"
35
    )
36
    default_url_platform_mapping = {
5✔
37
        "linux_arm64": "aarch64-unknown-linux-musl",
38
        "linux_x86_64": "x86_64-unknown-linux-musl",
39
        "macos_arm64": "aarch64-apple-darwin",
40
        "macos_x86_64": "x86_64-apple-darwin",
41
    }
42

43
    def generate_exe(self, plat: Platform) -> str:
5✔
UNCOV
44
        platform = self.default_url_platform_mapping[plat.value]
×
UNCOV
45
        return f"./uv-{platform}/uv"
×
46

47
    args_for_uv_pip_install = ArgsListOption(
5✔
48
        tool_name="uv",
49
        example="--index-strategy unsafe-first-match",
50
        extra_help=softwrap(
51
            """
52
            Additional arguments to pass to `uv pip install` invocations.
53

54
            Used when `[python].pex_builder = "uv"` to pass extra flags to the
55
            `uv pip install` step (e.g. `--index-url`, `--extra-index-url`).
56
            These are NOT passed to the `uv venv` step.
57
            """
58
        ),
59
    )
60

61

62
@dataclass(frozen=True)
5✔
63
class DownloadedUv:
5✔
64
    """The downloaded uv binary with user-configured args."""
65

66
    digest: Digest
5✔
67
    exe: str
5✔
68
    args_for_uv_pip_install: tuple[str, ...]
5✔
69

70

71
@rule
5✔
72
async def download_uv_binary(uv: Uv, platform: Platform) -> DownloadedUv:
5✔
UNCOV
73
    downloaded = await download_external_tool(uv.get_request(platform))
×
UNCOV
74
    return DownloadedUv(
×
75
        digest=downloaded.digest,
76
        exe=downloaded.exe,
77
        args_for_uv_pip_install=tuple(uv.args_for_uv_pip_install),
78
    )
79

80

81
def rules():
5✔
82
    return collect_rules()
5✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc