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

pantsbuild / pants / 18252174847

05 Oct 2025 01:36AM UTC coverage: 43.382% (-36.9%) from 80.261%
18252174847

push

github

web-flow
run tests on mac arm (#22717)

Just doing the minimal to pull forward the x86_64 pattern.

ref #20993

25776 of 59416 relevant lines covered (43.38%)

1.3 hits per line

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

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

4
from __future__ import annotations
×
5

6
from pants.backend.python.subsystems.python_tool_base import PythonToolBase
×
7
from pants.backend.python.target_types import ConsoleScript
×
8
from pants.core.goals.resolves import ExportableTool
×
9
from pants.core.util_rules.config_files import ConfigFilesRequest
×
10
from pants.engine.fs import CreateDigest
×
11
from pants.engine.rules import collect_rules
×
12
from pants.engine.unions import UnionRule
×
13
from pants.option.global_options import ca_certs_path_to_file_content
×
14
from pants.option.option_types import ArgsListOption, BoolOption, FileOption, SkipOption, StrOption
×
15
from pants.util.docutil import doc_url
×
16
from pants.util.strutil import softwrap
×
17

18

19
class TwineSubsystem(PythonToolBase):
×
20
    options_scope = "twine"
×
21
    name = "Twine"
×
22
    help_short = (
×
23
        "The utility for publishing Python distributions to PyPI and other Python repositories."
24
    )
25

26
    default_version = "twine>=4,<5"
×
27
    default_main = ConsoleScript("twine")
×
28

29
    default_requirements = [
×
30
        "twine>=3.7.1,<5",
31
        # This explicit dependency resolves a weird behavior in poetry, where it would include a
32
        # sys platform constraint on "Windows" when this was included transitively from the twine
33
        # requirements.
34
        # See: https://github.com/pantsbuild/pants/pull/13594#issuecomment-968154931
35
        "colorama>=0.4.3",
36
        # Remove this constraint once on twine > 5. See:
37
        # https://github.com/pypa/twine/issues/977
38
        # https://github.com/pypa/twine/issues/1125
39
        "importlib-metadata<8",
40
    ]
41

42
    register_interpreter_constraints = True
×
43

44
    default_lockfile_resource = ("pants.backend.python.subsystems", "twine.lock")
×
45

46
    skip = SkipOption("publish")
×
47
    args = ArgsListOption(example="--skip-existing")
×
48
    config = FileOption(
×
49
        default=None,
50
        advanced=True,
51
        help=lambda cls: softwrap(
52
            f"""
53
            Path to a .pypirc config file to use.
54
            (https://packaging.python.org/specifications/pypirc/)
55

56
            Setting this option will disable `[{cls.options_scope}].config_discovery`. Use
57
            this option if the config is located in a non-standard location.
58
            """
59
        ),
60
    )
61
    config_discovery = BoolOption(
×
62
        default=True,
63
        advanced=True,
64
        help=lambda cls: softwrap(
65
            f"""
66
            If true, Pants will include all relevant config files during runs (`.pypirc`).
67

68
            Use `[{cls.options_scope}].config` instead if your config is in a non-standard location.
69
            """
70
        ),
71
    )
72

73
    ca_certs_path = StrOption(
×
74
        advanced=True,
75
        default="<inherit>",
76
        help=softwrap(
77
            f"""
78
            Path to a file containing PEM-format CA certificates used for verifying secure
79
            connections when publishing python distributions.
80

81
            Uses the value from `[GLOBAL].ca_certs_path` by default. Set to `"<none>"` to
82
            not use any certificates.
83

84
            Even when using the `docker_environment` and `remote_environment` targets, this path
85
            will be read from the local host, and those certs will be used in the environment.
86

87
            This option cannot be overridden via environment targets, so if you need a different
88
            value than what the rest of your organization is using, override the value via an
89
            environment variable, CLI argument, or `.pants.rc` file. See {doc_url("docs/using-pants/key-concepts/options")}.
90
            """
91
        ),
92
    )
93

94
    def config_request(self) -> ConfigFilesRequest:
×
95
        # Refer to https://twine.readthedocs.io/en/latest/#configuration for how config files are
96
        # discovered.
97
        return ConfigFilesRequest(
×
98
            specified=self.config,
99
            specified_option_name=f"[{self.options_scope}].config",
100
            discovery=self.config_discovery,
101
            check_existence=[".pypirc"],
102
        )
103

104
    def ca_certs_digest_request(self, default_ca_certs_path: str | None) -> CreateDigest | None:
×
105
        path = default_ca_certs_path if self.ca_certs_path == "<inherit>" else self.ca_certs_path
×
106
        if not path or path == "<none>":
×
107
            return None
×
108
        return CreateDigest((ca_certs_path_to_file_content(path),))
×
109

110

111
def rules():
×
112
    return [
×
113
        *collect_rules(),
114
        UnionRule(ExportableTool, TwineSubsystem),
115
    ]
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