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

pantsbuild / pants / 19015773527

02 Nov 2025 05:33PM UTC coverage: 17.872% (-62.4%) from 80.3%
19015773527

Pull #22816

github

web-flow
Merge a12d75757 into 6c024e162
Pull Request #22816: Update Pants internal Python to 3.14

4 of 5 new or added lines in 3 files covered. (80.0%)

28452 existing lines in 683 files now uncovered.

9831 of 55007 relevant lines covered (17.87%)

0.18 hits per line

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

0.0
/src/python/pants/backend/python/util_rules/pex_venv.py
1
# Copyright 2023 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
UNCOV
3
from __future__ import annotations
×
4

UNCOV
5
from dataclasses import dataclass
×
UNCOV
6
from enum import Enum
×
UNCOV
7
from pathlib import Path
×
8

UNCOV
9
from pants.backend.python.util_rules import pex_cli
×
UNCOV
10
from pants.backend.python.util_rules.pex import CompletePlatforms, Pex, PexPlatforms
×
UNCOV
11
from pants.backend.python.util_rules.pex_cli import PexCliProcess
×
UNCOV
12
from pants.engine.fs import Digest
×
UNCOV
13
from pants.engine.internals.native_engine import MergeDigests
×
UNCOV
14
from pants.engine.intrinsics import merge_digests
×
UNCOV
15
from pants.engine.process import fallible_to_exec_result_or_raise
×
UNCOV
16
from pants.engine.rules import collect_rules, implicitly, rule
×
17

18

UNCOV
19
class PexVenvLayout(Enum):
×
UNCOV
20
    VENV = "venv"
×
UNCOV
21
    FLAT = "flat"
×
UNCOV
22
    FLAT_ZIPPED = "flat-zipped"
×
23

24

UNCOV
25
@dataclass(frozen=True)
×
UNCOV
26
class PexVenvRequest:
×
UNCOV
27
    pex: Pex
×
UNCOV
28
    layout: PexVenvLayout
×
UNCOV
29
    output_path: Path
×
UNCOV
30
    description: str
×
31

UNCOV
32
    platforms: PexPlatforms = PexPlatforms()
×
UNCOV
33
    complete_platforms: CompletePlatforms = CompletePlatforms()
×
UNCOV
34
    prefix: None | str = None
×
UNCOV
35
    extra_args: tuple[str, ...] = ()
×
36

37

UNCOV
38
@dataclass(frozen=True)
×
UNCOV
39
class PexVenv:
×
UNCOV
40
    digest: Digest
×
UNCOV
41
    path: Path
×
42

43

UNCOV
44
@rule
×
UNCOV
45
async def pex_venv(request: PexVenvRequest) -> PexVenv:
×
46
    # TODO: create the output with a fixed name and then rename
47
    # (https://github.com/pantsbuild/pants/issues/15102)
UNCOV
48
    if request.layout is PexVenvLayout.FLAT_ZIPPED:
×
49
        # --layout=flat-zipped takes --dest-dir=foo and zips it up to `foo.zip`, so we cannot
50
        # directly control the full path until we do a rename
51
        if request.output_path.suffix != ".zip":
×
52
            raise ValueError(
×
53
                f"layout=FLAT_ZIPPED requires output_path to end in '.zip', but found output_path='{request.output_path}' ending in {request.output_path.suffix!r}"
54
            )
55
        dest_dir = request.output_path.with_suffix("")
×
56
        output_files = [str(request.output_path)]
×
57
        output_directories = []
×
58
    else:
UNCOV
59
        dest_dir = request.output_path
×
UNCOV
60
        output_files = []
×
UNCOV
61
        output_directories = [str(request.output_path)]
×
62

UNCOV
63
    input_digest = await merge_digests(
×
64
        MergeDigests([request.pex.digest, request.complete_platforms.digest])
65
    )
UNCOV
66
    result = await fallible_to_exec_result_or_raise(
×
67
        **implicitly(
68
            PexCliProcess(
69
                subcommand=("venv", "create"),
70
                extra_args=(
71
                    f"--dest-dir={dest_dir}",
72
                    f"--pex-repository={request.pex.name}",
73
                    f"--layout={request.layout.value}",
74
                    *((f"--prefix={request.prefix}",) if request.prefix is not None else ()),
75
                    # NB. Specifying more than one of these args doesn't make sense for `venv
76
                    # create`. Incorrect usage will be surfaced as a subprocess failure.
77
                    *request.platforms.generate_pex_arg_list(),
78
                    *request.complete_platforms.generate_pex_arg_list(),
79
                    *request.extra_args,
80
                ),
81
                additional_input_digest=input_digest,
82
                output_files=output_files,
83
                output_directories=output_directories,
84
                description=request.description,
85
            )
86
        )
87
    )
UNCOV
88
    return PexVenv(digest=result.output_digest, path=request.output_path)
×
89

90

UNCOV
91
def rules():
×
UNCOV
92
    return [*collect_rules(), *pex_cli.rules()]
×
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