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

pantsbuild / pants / 24638277381

19 Apr 2026 08:21PM UTC coverage: 52.377% (-40.5%) from 92.924%
24638277381

Pull #23274

github

web-flow
Merge 662e70df2 into 0283af69e
Pull Request #23274: rust: upgrade to v1.95.0

31658 of 60443 relevant lines covered (52.38%)

1.05 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
# pants: infer-dep(twine.lock*)
19

20

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

28
    default_version = "twine>=4,<5"
×
29
    default_main = ConsoleScript("twine")
×
30

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

44
    register_interpreter_constraints = True
×
45

46
    default_lockfile_resource = ("pants.backend.python.subsystems", "twine.lock")
×
47

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

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

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

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

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

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

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

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

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

112

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