• 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

63.27
/src/python/pants/backend/build_files/fmt/ruff/integration_test.py
1
# Copyright 2024 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
from __future__ import annotations
2✔
5

6
import pytest
2✔
7

8
from pants.backend.build_files.fmt.ruff.register import RuffRequest
2✔
9
from pants.backend.build_files.fmt.ruff.register import rules as ruff_build_rules
2✔
10
from pants.backend.python.lint.ruff.check.rules import rules as ruff_fmt_rules
2✔
11
from pants.backend.python.lint.ruff.subsystem import rules as ruff_subsystem_rules
2✔
12
from pants.backend.python.target_types import PythonSourcesGeneratorTarget
2✔
13
from pants.core.goals.fmt import FmtResult
2✔
14
from pants.core.util_rules import config_files
2✔
15
from pants.engine.fs import PathGlobs
2✔
16
from pants.engine.internals.native_engine import Snapshot
2✔
17
from pants.testutil.rule_runner import QueryRule, RuleRunner
2✔
18

19

20
@pytest.fixture
2✔
21
def rule_runner() -> RuleRunner:
2✔
22
    return RuleRunner(
2✔
23
        rules=[
24
            *ruff_build_rules(),
25
            *ruff_fmt_rules(),
26
            *ruff_subsystem_rules(),
27
            *config_files.rules(),
28
            QueryRule(FmtResult, (RuffRequest.Batch,)),
29
        ],
30
        target_types=[PythonSourcesGeneratorTarget],
31
    )
32

33

34
def run_ruff(rule_runner: RuleRunner, *, extra_args: list[str] | None = None) -> FmtResult:
2✔
35
    rule_runner.set_options(
2✔
36
        ["--backend-packages=pants.backend.build_files.fmt.ruff", *(extra_args or ())],
37
        env_inherit={"PATH", "PYENV_ROOT", "HOME"},
38
    )
39
    snapshot = rule_runner.request(Snapshot, [PathGlobs(["**/BUILD"])])
2✔
40
    fmt_result = rule_runner.request(
2✔
41
        FmtResult,
42
        [
43
            RuffRequest.Batch("", snapshot.files, partition_metadata=None, snapshot=snapshot),
44
        ],
45
    )
46
    return fmt_result
2✔
47

48

49
@pytest.mark.platform_specific_behavior
2✔
50
def test_passing(rule_runner: RuleRunner) -> None:
2✔
51
    rule_runner.write_files({"BUILD": 'python_sources(name="t")\n'})
2✔
52
    fmt_result = run_ruff(
2✔
53
        rule_runner,
54
    )
55
    assert "1 file left unchanged" in fmt_result.stdout
2✔
56
    assert fmt_result.output == rule_runner.make_snapshot({"BUILD": 'python_sources(name="t")\n'})
2✔
57
    assert fmt_result.did_change is False
2✔
58

59

60
def test_failing(rule_runner: RuleRunner) -> None:
2✔
UNCOV
61
    rule_runner.write_files({"BUILD": "python_sources(name='t')\n"})
×
UNCOV
62
    fmt_result = run_ruff(rule_runner)
×
UNCOV
63
    assert "1 file reformatted" in fmt_result.stdout
×
UNCOV
64
    assert fmt_result.output == rule_runner.make_snapshot({"BUILD": 'python_sources(name="t")\n'})
×
UNCOV
65
    assert fmt_result.did_change is True
×
66

67

68
def test_multiple_files(rule_runner: RuleRunner) -> None:
2✔
UNCOV
69
    rule_runner.write_files(
×
70
        {
71
            "good/BUILD": 'python_sources(name="t")\n',
72
            "bad/BUILD": "python_sources(name='t')\n",
73
        }
74
    )
UNCOV
75
    fmt_result = run_ruff(rule_runner)
×
UNCOV
76
    assert "1 file reformatted, 1 file left unchanged" in fmt_result.stdout
×
UNCOV
77
    assert fmt_result.output == rule_runner.make_snapshot(
×
78
        {"good/BUILD": 'python_sources(name="t")\n', "bad/BUILD": 'python_sources(name="t")\n'}
79
    )
UNCOV
80
    assert fmt_result.did_change is True
×
81

82

83
@pytest.mark.parametrize(
2✔
84
    "config_path,extra_args",
85
    (["pyproject.toml", []], ["custom_config.toml", ["--ruff-config=custom_config.toml"]]),
86
)
87
def test_config_file(rule_runner: RuleRunner, config_path: str, extra_args: list[str]) -> None:
2✔
88
    # Force single-quote formatting to pass config and ensure there are no changes.
89
    # Use the `tool.ruff` key in pyproject.toml, but don't include in custom config.
UNCOV
90
    config_content = (
×
91
        '[tool.ruff.format]\nquote-style = "single"\n'
92
        if config_path == "pyproject.toml"
93
        else '[format]\nquote-style = "single"\n'
94
    )
UNCOV
95
    rule_runner.write_files(
×
96
        {
97
            "BUILD": "python_sources(name='t')\n",
98
            config_path: config_content,
99
        }
100
    )
UNCOV
101
    before_file_content = rule_runner.read_file("BUILD")
×
UNCOV
102
    fmt_result = run_ruff(rule_runner, extra_args=extra_args)
×
UNCOV
103
    after_file_content = rule_runner.read_file("BUILD")
×
104

UNCOV
105
    assert before_file_content == after_file_content
×
UNCOV
106
    assert fmt_result.output == rule_runner.make_snapshot({"BUILD": "python_sources(name='t')\n"})
×
UNCOV
107
    assert fmt_result.did_change is False
×
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