• 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/fields/all.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
from enum import Enum
×
UNCOV
7
from typing import ClassVar
×
8

UNCOV
9
from pants.backend.nfpm.subsystem import MTIME_DEFAULT
×
UNCOV
10
from pants.core.goals.package import OutputPathField
×
UNCOV
11
from pants.engine.target import Dependencies, StringField
×
UNCOV
12
from pants.util.docutil import bin_name
×
UNCOV
13
from pants.util.strutil import help_text
×
14

15

UNCOV
16
class NfpmPackageNameField(StringField):
×
UNCOV
17
    nfpm_alias = "name"
×
UNCOV
18
    alias: ClassVar[str] = "package_name"
×
UNCOV
19
    required = True
×
UNCOV
20
    value: str
×
UNCOV
21
    help = help_text(
×
22
        """
23
        The package name.
24
        """
25
    )
26

27

UNCOV
28
class NfpmPackageMtimeField(StringField):
×
UNCOV
29
    nfpm_alias = ""  # field handled separately to call normalized_value
×
UNCOV
30
    alias: ClassVar[str] = "mtime"
×
UNCOV
31
    default = MTIME_DEFAULT
×
UNCOV
32
    help = help_text(
×
33
        f"""
34
        The file modification time as an RFC 3339 formatted string.
35

36
        For example: 2008-01-02T15:04:05Z
37

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

40
        NOTE: This field does NOT set the mtime for package contents. It sets the
41
        build time in package metadata (for package types that have that metadata),
42
        as well as the file modification time for files that nFPM generates in the
43
        package. To set the mtime for package contents, use the `file_mtime` field
44
        on the relevant `nfpm_content_*` targets.
45

46
        The default value is {repr(MTIME_DEFAULT)}. You may also override
47
        the default value by setting `[nfpm].default_mtime` in `pants.toml`,
48
        or by setting the `SOURCE_DATE_EPOCH` environment variable.
49

50
        See also: https://reproducible-builds.org/docs/timestamps/
51
        """
52
    )
53

UNCOV
54
    def normalized_value(self, default_mtime: str | None):
×
55
        # This protects against an empty SOURCE_DATE_EPOCH var as mtime must not be empty.
UNCOV
56
        if self.value == self.default and default_mtime and self.value != default_mtime:
×
57
            return default_mtime
×
UNCOV
58
        return self.value
×
59

60

UNCOV
61
class NfpmDependencies(Dependencies):
×
UNCOV
62
    nfpm_alias = ""  # doesn't map directly to a nfpm.yaml field
×
63

64

UNCOV
65
class NfpmArch(Enum):
×
66
    # nFPM uses arch = GOARCH + GOARM. See: https://nfpm.goreleaser.com/goarch-to-pkg/
67
    # GOARCH possible values come from `okgoarch` var at:
68
    # https://github.com/golang/go/blob/go1.20.3/src/cmd/dist/build.go#L62-L79
69
    # GOARM possible values come from `goarm()` func at:
70
    # https://github.com/golang/go/blob/go1.20.3/src/internal/buildcfg/cfg.go#L77-L84
UNCOV
71
    _386 = "386"
×
UNCOV
72
    all = "all"  # not in `okgoarch`, but a conventionally accepted GOARCH value.
×
UNCOV
73
    amd64 = "amd64"
×
UNCOV
74
    arm5 = "arm5"  # GOARCH=arm GOARM=5
×
UNCOV
75
    arm6 = "arm6"  # GOARCH=arm GOARM=6
×
UNCOV
76
    arm7 = "arm7"  # GOARCH=arm GOARM=7
×
UNCOV
77
    arm64 = "arm64"  # GOARCH=arm64
×
UNCOV
78
    loong64 = "loong64"
×
UNCOV
79
    mips = "mips"
×
UNCOV
80
    mipsle = "mipsle"
×
UNCOV
81
    mips64 = "mips64"
×
UNCOV
82
    mips64le = "mips64le"
×
UNCOV
83
    ppc64 = "ppc64"
×
UNCOV
84
    ppc64le = "ppc64le"
×
UNCOV
85
    riscv64 = "riscv64"
×
UNCOV
86
    s390 = "s390"  # not in `okgoarch`; nFPM translates it to "s390x".
×
UNCOV
87
    s390x = "s390x"
×
UNCOV
88
    sparc64 = "sparc64"
×
UNCOV
89
    wasm = "wasm"
×
90

91

UNCOV
92
class NfpmArchField(StringField):
×
UNCOV
93
    nfpm_alias = "arch"
×
UNCOV
94
    alias: ClassVar[str] = nfpm_alias
×
95
    # valid_choices = NfpmArch  # no valid_choices to support pass-through values.
UNCOV
96
    default = NfpmArch.amd64.value  # based on nFPM default
×
UNCOV
97
    help = help_text(
×
98
        f"""
99
        The package architecture.
100

101
        This should be a valid GOARCH value (or GOARCH+GOARM) that nFPM can
102
        convert into the package-specific equivalent. Otherwise, pants tells
103
        nFPM to use this value as-is.
104

105
        nFPM conversion from GOARCH to package-specific value is documented here:
106
        https://nfpm.goreleaser.com/goarch-to-pkg/
107

108
        Use one of these values unless you need nFPM to use your value as-is:
109
        `{" | ".join(repr(arch.value) for arch in NfpmArch.__members__.values())}`
110
        """
111
    )
112

113

UNCOV
114
class NfpmPlatformField(StringField):
×
UNCOV
115
    nfpm_alias = "platform"
×
UNCOV
116
    alias: ClassVar[str] = nfpm_alias
×
117
    # no valid_choices to support pass-through values.
UNCOV
118
    default = "linux"  # based on nFPM default
×
UNCOV
119
    help = help_text(
×
120
        """
121
        The package platform or OS.
122

123
        You probably do not need to change the package's OS. nFPM is designed
124
        with the assumption that this is a GOOS value (since nFPM is part of the
125
        "goreleaser" project). But, nFPM does not do much with it.
126

127
        For archlinux and apk, the only valid value is 'linux'.
128
        For deb, this can be used as part of the 'Architecture' entry.
129
        For rpm, this populates the "OS" tag.
130
        """
131
    )
132

133

UNCOV
134
class NfpmHomepageField(StringField):
×
UNCOV
135
    nfpm_alias = "homepage"
×
UNCOV
136
    alias: ClassVar[str] = nfpm_alias
×
UNCOV
137
    help = help_text(
×
138
        lambda: f"""
139
        The URL of this package's homepage like "https://example.com".
140

141
        This field is named "{NfpmHomepageField.alias}" instead of "url" because
142
        that is the term used by nFPM, which adopted the term from deb packaging.
143
        The term "url" is used by apk, archlinux, and rpm packaging.
144
        """
145
    )
146

147

UNCOV
148
class NfpmLicenseField(StringField):
×
UNCOV
149
    nfpm_alias = "license"
×
UNCOV
150
    alias: ClassVar[str] = nfpm_alias
×
UNCOV
151
    help = help_text(
×
152
        """
153
        The license of this package.
154

155
        Where possible, please try to use the SPDX license identifiers (for
156
        example "Apache-2.0", "BSD-3-Clause", "GPL-3.0-or-later", or "MIT"):
157
        https://spdx.org/licenses/
158

159
        For more complex cases, where the package includes software with multiple
160
        licenses, consider using an SPDX license expression:
161
        https://spdx.github.io/spdx-spec/v2.3/SPDX-license-expressions/
162

163
        See also these rpm-specific descriptions of how to set this field (this
164
        is helpful info even if you are not using rpm):
165
        https://docs.fedoraproject.org/en-US/legal/license-field/
166

167
        nFPM does not yet generate the debian/copyright file, so this field is
168
        technically unused for now. Even for deb, we recommend using this field
169
        to document the software license for this package. See also these pages
170
        about specifying a license for deb packaging:
171
        https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/#license-specification
172
        https://wiki.debian.org/Proposals/CopyrightFormat#Differences_between_DEP5_and_SPDX
173
        """
174
    )
175

176

UNCOV
177
class NfpmOutputPathField(OutputPathField):
×
UNCOV
178
    nfpm_alias = ""
×
UNCOV
179
    help = help_text(
×
180
        f"""
181
        Where the built directory tree should be located.
182

183
        If undefined, this will use the path to the BUILD file, followed by the target name.
184
        For example, `src/project/packaging:rpm` would be `src.project.packaging/rpm/`.
185

186
        Regardless of whether you use the default or set this field, the package's file name
187
        will have the packaging system's conventional filename (as understood by nFPM).
188
        So, an rpm using the default for this field, the target `src/project/packaging:rpm`
189
        might have a final path like `src.project.packaging/rpm/projectname-1.2.3-1.x86_64.rpm`.
190
        Similarly, for deb, the target `src/project/packaging:deb` might have a final path like
191
        `src.project.packaging/deb/projectname_1.2.3+git-1_x86_64.deb`. The other packagers
192
        have their own formats as well.
193

194
        When running `{bin_name()} package`, this path will be prefixed by `--distdir` (e.g. `dist/`).
195

196
        Warning: setting this value risks naming collisions with other package targets you may have.
197
        """
198
    )
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