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

pantsbuild / pants / 20280382299

16 Dec 2025 07:36PM UTC coverage: 80.266% (-0.03%) from 80.293%
20280382299

Pull #22949

github

web-flow
Merge 21fe9958b into 5605e9825
Pull Request #22949: Add experimental uv resolver for Python lockfiles

51 of 96 new or added lines in 5 files covered. (53.13%)

2 existing lines in 1 file now uncovered.

78534 of 97842 relevant lines covered (80.27%)

3.1 hits per line

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

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

4
from __future__ import annotations
11✔
5

6
from pants.core.goals.resolves import ExportableTool
11✔
7
from pants.core.util_rules.external_tool import TemplatedExternalTool
11✔
8
from pants.engine.platform import Platform
11✔
9
from pants.engine.rules import collect_rules
11✔
10
from pants.engine.unions import UnionRule
11✔
11
from pants.option.option_types import ArgsListOption
11✔
12
from pants.util.strutil import softwrap
11✔
13

14

15
class Uv(TemplatedExternalTool):
11✔
16
    options_scope = "uv"
11✔
17
    name = "uv"
11✔
18
    help = "The uv Python package manager (https://github.com/astral-sh/uv)."
11✔
19

20
    default_version = "0.9.5"
11✔
21
    default_known_versions = [
11✔
22
        "0.9.5|macos_x86_64|58b1d4a25aa8ff99147c2550b33dcf730207fe7e0f9a0d5d36a1bbf36b845aca|19689319",
23
        "0.9.5|macos_arm64|dc098ff224d78ed418e121fd374f655949d2c7031a70f6f6604eaf016a130433|18341942",
24
        "0.9.5|linux_x86_64|3665ffb6c429c31ad6c778ac0489b7746e691acf025cf530b3510b2f9b1660ff|21566106",
25
        "0.9.5|linux_arm64|42b9b83933a289fe9c0e48f4973dee49ce0dfb95e19ea0b525ca0dbca3bce71f|20079609",
26
    ]
27
    version_constraints = ">=0.0.0,<1"
11✔
28

29
    default_url_template = (
11✔
30
        "https://github.com/astral-sh/uv/releases/download/{version}/uv-{platform}.tar.gz"
31
    )
32
    default_url_platform_mapping = {
11✔
33
        # NB. Prefer musl over gnu, for increased compatibility.
34
        "linux_arm64": "aarch64-unknown-linux-musl",
35
        "linux_x86_64": "x86_64-unknown-linux-musl",
36
        "macos_arm64": "aarch64-apple-darwin",
37
        "macos_x86_64": "x86_64-apple-darwin",
38
    }
39

40
    def generate_exe(self, plat: Platform) -> str:
11✔
NEW
41
        platform = self.default_url_platform_mapping[plat.value]
×
NEW
42
        return f"./uv-{platform}/uv"
×
43

44
    args = ArgsListOption(
11✔
45
        passthrough=True,
46
        tool_name="uv pip compile",
47
        example="--index-strategy unsafe-first-match --resolution lowest-direct",
48
        extra_help=softwrap(
49
            """
50
            Only used when `[python].lockfile_resolver = "uv"`.
51

52
            For example, to prefer the first index that provides a given package, set:
53

54
                [uv]
55
                args = ["--index-strategy", "unsafe-first-match"]
56
            """
57
        ),
58
    )
59

60

61
def rules():
11✔
62
    return [*collect_rules(), UnionRule(ExportableTool, Uv)]
4✔
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

© 2025 Coveralls, Inc