• 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/nfpm/subsystem.py
1
# Copyright 2023 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
import logging
×
7

UNCOV
8
from pants.core.goals.resolves import ExportableTool
×
UNCOV
9
from pants.core.util_rules import external_tool
×
UNCOV
10
from pants.core.util_rules.external_tool import TemplatedExternalTool
×
UNCOV
11
from pants.engine.platform import Platform
×
UNCOV
12
from pants.engine.unions import UnionRule
×
UNCOV
13
from pants.option.option_types import StrOption
×
UNCOV
14
from pants.option.subsystem import Subsystem
×
UNCOV
15
from pants.util.strutil import softwrap
×
16

UNCOV
17
logger = logging.getLogger(__name__)
×
18

19
# Default copied from PEX (which uses zipfile standard MS-DOS epoch).
20
# https://github.com/pex-tool/pex/blob/v2.1.137/pex/common.py#L39-L45
UNCOV
21
MTIME_DEFAULT = "1980-01-01T00:00:00Z"
×
22

23

UNCOV
24
class NfpmSubsystem(TemplatedExternalTool):
×
UNCOV
25
    name = "nFPM"
×
UNCOV
26
    options_scope = "nfpm"
×
UNCOV
27
    help = "The nFPM deb, rpm, apk, and archlinux packager (https://nfpm.goreleaser.com)."
×
28

29
    # The version WITHOUT the 'v' prefix which we add as needed in the url_template.
UNCOV
30
    default_version = "2.41.3"
×
31
    # v2.35.0 added SOURCE_DATE_EPOCH support
32
    # v2.36.0 added rpm.scripts.verify
33
    # v2.37.0 added support for IPK packaging (TODO: add IPK package target+fields+rules)
UNCOV
34
    default_known_versions = [
×
35
        "2.41.3|macos_x86_64|ad200ce58db4a980b79a6cf182ae69e4b3ffc6f30af722396ba4dadaa54a535e|5735548",
36
        "2.41.3|macos_arm64|8f053cb9e01ffaa32b929dbf73d34f0a81d135044751f8d4138a418064ee5ae5|5370742",
37
        "2.41.3|linux_x86_64|22aa6d3bc2ec239d62d3d190bcb036a47f2b24e0c3c6edfccebb6a55fbb2078e|5642686",
38
        "2.41.3|linux_arm64|f20852f79109c8a77cb19150d26fc5c5a0d3bbde33bf46a76341e434ea411225|5174782",
39
        "2.38.0|win_x86_64|3124f9bb838410ef98eebfed2267670790ce6bb262ae2a6ca1938a69e087593b|5389117",
40
        "2.38.0|win_arm64|1a9c7fcd50eb105231f6f6f6cb90d7cdf50e6c34665eb6e881a185387ad158b1|4888861",
41
        "2.38.0|macos_x86_64|781420f18ed6bd84a437fe3b272c1b1a03bad546aaaf4f7251b21c25a24ce32b|5294310",
42
        "2.38.0|macos_arm64|48788831696cf056b1a0f9f52e187dbb65c191f5488962696ab3b98fff9f7821|4978997",
43
        "2.38.0|linux_x86_64|d9eebe93ee2832cfc8435b3f79ee92a845f1e5fbb99db5a3777a0013e175170d|5196368",
44
        "2.38.0|linux_arm64|e63be8d586d7c8f6af06945956aa29fb88388caa19d7c5b652f41ae37a155b27|4780662",
45
    ]
46

UNCOV
47
    default_url_template = (
×
48
        "https://github.com/goreleaser/nfpm/releases/download/v{version}/nfpm_{version}_{platform}"
49
    )
50

UNCOV
51
    default_url_platform_mapping = {
×
52
        # Platform includes the extension because Windows uses .zip instead of .tar.gz
53
        "macos_arm64": "Darwin_arm64.tar.gz",
54
        "macos_x86_64": "Darwin_x86_64.tar.gz",
55
        "linux_arm64": "Linux_arm64.tar.gz",
56
        "linux_x86_64": "Linux_x86_64.tar.gz",
57
        "win_arm64": "Windows_arm64.zip",
58
        "win_x86_64": "Windows_x86_64.zip",
59
    }
60

61
    # all args controlled via target options
62
    # config file generated based on target options
63

UNCOV
64
    def generate_exe(self, plat: Platform) -> str:
×
65
        return "./nfpm"
×
66

UNCOV
67
    class EnvironmentAware(Subsystem.EnvironmentAware):
×
UNCOV
68
        env_vars_used_by_options = ("SORCE_DATE_EPOCH",)
×
69

UNCOV
70
        _default_mtime = StrOption(
×
71
            default=MTIME_DEFAULT,
72
            help=softwrap(
73
                f"""
74
                The file modification time as an RFC 3339 formatted string.
75

76
                For example: 2008-01-02T15:04:05Z
77

78
                The format is defined in RFC 3339: https://rfc-editor.org/rfc/rfc3339.html
79

80
                This option sets the default value for:
81
                - the `package_mtime` field on `nfpm_*_package` targets, and
82
                - the `file_mtime` field on `nfpm_content_*` targets.
83

84
                The default value is {repr(MTIME_DEFAULT)}. You may also
85
                set the SOURCE_DATE_EPOCH environment variable to override this default.
86

87
                See also: https://reproducible-builds.org/docs/timestamps/
88
                """
89
            ),
90
        )
91

UNCOV
92
        @property
×
UNCOV
93
        def default_mtime(self) -> str:
×
94
            default_mtime = self._default_mtime
×
95
            if default_mtime != MTIME_DEFAULT:
×
96
                return default_mtime
×
97
            source_date_epoch = self._options_env.get("SOURCE_DATE_EPOCH", "")
×
98
            return source_date_epoch if source_date_epoch else default_mtime
×
99

100

UNCOV
101
def rules():
×
UNCOV
102
    return [
×
103
        *external_tool.rules(),
104
        *NfpmSubsystem.rules(),
105
        UnionRule(ExportableTool, NfpmSubsystem),
106
    ]
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