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

pantsbuild / pants / 19015773527

02 Nov 2025 05:33PM UTC coverage: 17.872% (-62.4%) from 80.3%
19015773527

Pull #22816

github

web-flow
Merge a12d75757 into 6c024e162
Pull Request #22816: Update Pants internal Python to 3.14

4 of 5 new or added lines in 3 files covered. (80.0%)

28452 existing lines in 683 files now uncovered.

9831 of 55007 relevant lines covered (17.87%)

0.18 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

UNCOV
4
from __future__ import annotations
×
5

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

18

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

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

UNCOV
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

UNCOV
42
    register_interpreter_constraints = True
×
43

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

UNCOV
46
    skip = SkipOption("publish")
×
UNCOV
47
    args = ArgsListOption(example="--skip-existing")
×
UNCOV
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
    )
UNCOV
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

UNCOV
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

UNCOV
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

UNCOV
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

UNCOV
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