• 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

0.0
/src/python/pants/backend/codegen/python_format_string/k8s/rules.py
1
# Copyright 2025 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 pants.backend.codegen.python_format_string.target_types import (
×
6
    PythonFormatStringOutputPathField,
7
    PythonFormatStringSourceField,
8
    PythonFormatStringValuesField,
9
)
UNCOV
10
from pants.backend.k8s.target_types import K8sSourceField
×
UNCOV
11
from pants.engine.fs import CreateDigest, FileContent
×
UNCOV
12
from pants.engine.internals.graph import hydrate_sources
×
UNCOV
13
from pants.engine.intrinsics import digest_to_snapshot, get_digest_contents
×
UNCOV
14
from pants.engine.rules import collect_rules, implicitly, rule
×
UNCOV
15
from pants.engine.target import GeneratedSources, GenerateSourcesRequest, HydrateSourcesRequest
×
UNCOV
16
from pants.engine.unions import UnionRule
×
17

18

UNCOV
19
class GenerateK8sSourceFromPythonFormatStringRequest(GenerateSourcesRequest):
×
UNCOV
20
    input = PythonFormatStringSourceField
×
UNCOV
21
    output = K8sSourceField
×
22

23

UNCOV
24
@rule
×
UNCOV
25
async def generate_k8s_source(
×
26
    request: GenerateK8sSourceFromPythonFormatStringRequest,
27
) -> GeneratedSources:
28
    format_string_target = request.protocol_target
×
29
    hydrated_sources = await hydrate_sources(
×
30
        HydrateSourcesRequest(format_string_target[PythonFormatStringSourceField]), **implicitly()
31
    )
32

33
    if len(hydrated_sources.snapshot.files) != 1:
×
34
        raise ValueError(f"Expected single source, got {hydrated_sources.snapshot.files}")
×
35

36
    values = format_string_target[PythonFormatStringValuesField].value
×
37
    if values is None:
×
38
        raise ValueError(f"`{PythonFormatStringValuesField.alias}` is required")
×
39

40
    contents = await get_digest_contents(hydrated_sources.snapshot.digest)
×
41
    content = contents[0].content.decode("utf-8")
×
42
    try:
×
43
        rendered = content.format(**values)
×
44
    except KeyError as e:
×
45
        raise ValueError(
×
46
            f"Missing key in target `{format_string_target.address}`: {e}, provided values: {values}"
47
        ) from e
48
    except IndexError as e:
×
49
        raise ValueError(f"Failed to render target `{format_string_target.address}`") from e
×
50

51
    path = format_string_target[PythonFormatStringOutputPathField].value_or_default(
×
52
        file_ending="rendered"
53
    )
54
    snapshot = await digest_to_snapshot(
×
55
        **implicitly(CreateDigest([FileContent(path=path, content=rendered.encode("utf-8"))]))
56
    )
57
    return GeneratedSources(snapshot)
×
58

59

UNCOV
60
def rules():
×
UNCOV
61
    return (
×
62
        *collect_rules(),
63
        UnionRule(GenerateSourcesRequest, GenerateK8sSourceFromPythonFormatStringRequest),
64
    )
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