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

pantsbuild / pants / 20147226056

11 Dec 2025 08:58PM UTC coverage: 78.827% (-1.5%) from 80.293%
20147226056

push

github

web-flow
Forwarded the `style` and `complete-platform` args from pants.toml to PEX (#22910)

## Context

After Apple switched to the `arm64` architecture, some package
publishers stopped releasing `x86_64` variants of their packages for
`darwin`. As a result, generating a universal lockfile now fails because
no single package version is compatible with both `x86_64` and `arm64`
on `darwin`.

The solution is to use the `--style` and `--complete-platform` flags
with PEX. For example:
```
pex3 lock create \
    --style strict \
    --complete-platform 3rdparty/platforms/manylinux_2_28_aarch64.json \
    --complete-platform 3rdparty/platforms/macosx_26_0_arm64.json \
    -r 3rdparty/python/requirements_pyarrow.txt \
    -o python-pyarrow.lock
```

See the Slack discussion here:
https://pantsbuild.slack.com/archives/C046T6T9U/p1760098582461759

## Reproduction

* `BUILD`
```
python_requirement(
    name="awswrangler",
    requirements=["awswrangler==3.12.1"],
    resolve="awswrangler",
)
```
* Run `pants generate-lockfiles --resolve=awswrangler` on macOS with an
`arm64` CPU
```
pip: ERROR: Cannot install awswrangler==3.12.1 because these package versions have conflicting dependencies.
pip: ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
pip:  
pip:  The conflict is caused by:
pip:      awswrangler 3.12.1 depends on pyarrow<18.0.0 and >=8.0.0; sys_platform == "darwin" and platform_machine == "x86_64"
pip:      awswrangler 3.12.1 depends on pyarrow<21.0.0 and >=18.0.0; sys_platform != "darwin" or platform_machine != "x86_64"
pip:  
pip:  Additionally, some packages in these conflicts have no matching distributions available for your environment:
pip:      pyarrow
pip:  
pip:  To fix this you could try to:
pip:  1. loosen the range of package versions you've specified
pip:  2. remove package versions to allow pip to attempt to solve the dependency conflict
```

## Implementation
... (continued)

77 of 100 new or added lines in 6 files covered. (77.0%)

868 existing lines in 42 files now uncovered.

74471 of 94474 relevant lines covered (78.83%)

3.18 hits per line

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

71.43
/src/python/pants/engine/internals/target_adaptor.py
1
# Copyright 2020 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
import dataclasses
11✔
7
from dataclasses import dataclass
11✔
8
from typing import Any, final
11✔
9

10
from pants.build_graph.address import Address
11✔
11
from pants.engine.engine_aware import EngineAwareParameter
11✔
12
from pants.util.frozendict import FrozenDict
11✔
13
from pants.util.ordered_set import FrozenOrderedSet
11✔
14
from pants.vcs.hunk import TextBlock
11✔
15

16

17
@dataclass(frozen=True)
11✔
18
class SourceBlock:
11✔
19
    """Block of lines in a file.
20

21
    Lines are 1 indexed, `start` is inclusive, `end` is exclusive.
22

23
    SourceBlock is used to describe a set of source lines that are owned by a Target,
24
    thus it can't be empty, i.e. `start` must be less than `end`.
25
    """
26

27
    start: int
11✔
28
    end: int
11✔
29

30
    def __init__(self, start: int, end: int):
11✔
31
        object.__setattr__(self, "start", start)
1✔
32
        object.__setattr__(self, "end", end)
1✔
33

34
        self.__post_init__()
1✔
35

36
    def __post_init__(self):
11✔
37
        if self.start >= self.end:
1✔
38
            raise ValueError(f"{self.start=} must be less than {self.end=}")
×
39

40
    def __len__(self) -> int:
11✔
41
        return self.end - self.start
×
42

43
    def is_touched_by(self, o: TextBlock) -> bool:
11✔
44
        """Check if the TextBlock touches the SourceBlock.
45

46
        The function behaves similarly to range intersection check, but some edge cases are
47
        different. See test cases for details.
48
        """
49

UNCOV
50
        if o.count == 0:
×
UNCOV
51
            start = o.start + 1
×
UNCOV
52
            end = start
×
53
        else:
UNCOV
54
            start = o.start
×
UNCOV
55
            end = o.end
×
56

UNCOV
57
        if self.end < start:
×
UNCOV
58
            return False
×
UNCOV
59
        if end < self.start:
×
UNCOV
60
            return False
×
UNCOV
61
        return True
×
62

63
    @classmethod
11✔
64
    def from_text_block(cls, text_block: TextBlock) -> SourceBlock:
11✔
65
        """Convert (start, count) range to (start, end) range.
66

67
        Useful for unified diff conversion, see
68
        https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html
69
        """
70
        return cls(start=text_block.start, end=text_block.start + text_block.count)
×
71

72

73
class SourceBlocks(FrozenOrderedSet[SourceBlock]):
11✔
74
    pass
11✔
75

76

77
@dataclass(frozen=True)
11✔
78
class TargetAdaptorRequest(EngineAwareParameter):
11✔
79
    """Lookup the TargetAdaptor for an Address."""
80

81
    address: Address
11✔
82
    description_of_origin: str = dataclasses.field(hash=False, compare=False)
11✔
83

84
    def debug_hint(self) -> str:
11✔
85
        return self.address.spec
×
86

87

88
@final
11✔
89
class TargetAdaptor:
11✔
90
    """A light-weight object to store target information before being converted into the Target
91
    API."""
92

93
    __slots__ = ("type_alias", "name", "kwargs", "description_of_origin", "origin_sources_blocks")
11✔
94

95
    def __init__(
11✔
96
        self,
97
        type_alias: str,
98
        name: str | None,
99
        __description_of_origin__: str,
100
        __origin_sources_blocks__: FrozenDict[str, SourceBlocks] = FrozenDict(),
101
        **kwargs: Any,
102
    ) -> None:
103
        self.type_alias = type_alias
3✔
104
        self.name = name
3✔
105
        try:
3✔
106
            self.kwargs = FrozenDict.deep_freeze(kwargs)
3✔
107
        except TypeError as e:
×
108
            # FrozenDict's ctor eagerly computes its hash. If some kwarg is unhashable it will
109
            # raise a TypeError, which we enhance with the description of origin.
110
            raise TypeError(f"In {__description_of_origin__}: {e}")
×
111
        self.description_of_origin = __description_of_origin__
3✔
112
        self.origin_sources_blocks = __origin_sources_blocks__
3✔
113

114
    def with_new_kwargs(self, **kwargs) -> TargetAdaptor:
11✔
115
        return TargetAdaptor(
1✔
116
            type_alias=self.type_alias,
117
            name=self.name,
118
            __description_of_origin__=self.description_of_origin,
119
            __origin_sources_blocks__=self.origin_sources_blocks,
120
            **kwargs,
121
        )
122

123
    def __repr__(self) -> str:
11✔
124
        maybe_blocks = f", {self.origin_sources_blocks}" if self.origin_sources_blocks else ""
×
125
        return f"TargetAdaptor(type_alias={self.type_alias}, name={self.name}, origin={self.description_of_origin}{maybe_blocks})"
×
126

127
    def __eq__(self, other: Any | TargetAdaptor) -> bool:
11✔
128
        if not isinstance(other, TargetAdaptor):
1✔
129
            return NotImplemented
×
130
        return (
1✔
131
            self.type_alias == other.type_alias
132
            and self.name == other.name
133
            and self.kwargs == other.kwargs
134
        )
135

136
    def __hash__(self) -> int:
11✔
137
        return hash((self.type_alias, self.name, self.kwargs))
1✔
138

139
    @property
11✔
140
    def name_explicitly_set(self) -> bool:
11✔
141
        return self.name is not None
×
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