• 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/debian/target_types.py
1
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3
from collections.abc import Sequence
×
4
from pathlib import PurePath
×
5

6
from pants.core.goals.package import OutputPathField
×
7
from pants.engine.target import (
×
8
    COMMON_TARGET_FIELDS,
9
    DictStringToStringField,
10
    InvalidFieldException,
11
    MultipleSourcesField,
12
    SpecialCasedDependencies,
13
    StringField,
14
    Target,
15
)
16
from pants.util.docutil import bin_name, doc_url
×
17
from pants.util.strutil import help_text, softwrap
×
18

19

20
class DebianSources(MultipleSourcesField):
×
21
    required = True
×
22
    help = help_text(
×
23
        """
24
        Paths that will be included in the package to be produced such as Debian metadata files.
25
        You must include a DEBIAN/control file.
26

27
        Paths are relative to the BUILD file's directory and all paths must belong to the same parent directory.
28
        For example, `sources=['dir/**']` is valid, but `sources=['top_level_file.txt']`
29
        and `sources=['dir1/*', 'dir2/*']` are not.
30
        """
31
    )
32

33
    def validate_resolved_files(self, files: Sequence[str]) -> None:
×
34
        """Check that all files are coming from the same directory."""
35
        super().validate_resolved_files(files)
×
36
        if not files:
×
37
            raise InvalidFieldException(
×
38
                softwrap(
39
                    f"""
40
                    The `{self.alias}` field in target `{self.address}` must
41
                    resolve to at least one file.
42
                    """
43
                )
44
            )
45

46
        files_outside_dirs = [f for f in files if len(PurePath(f).parts) == 1]
×
47
        if files_outside_dirs:
×
48
            raise InvalidFieldException(
×
49
                softwrap(
50
                    f"""
51
                    The `{self.alias}` field in target `{self.address}` must be paths to
52
                    files in a single sources directory. Individual files
53
                    were found: {files_outside_dirs}
54
                    """
55
                )
56
            )
57

58
        directory_prefixes = {PurePath(f).parts[0] for f in files}
×
59
        if len(directory_prefixes) > 1:
×
60
            raise InvalidFieldException(
×
61
                softwrap(
62
                    f"""
63
                    The `{self.alias}` field in target `{self.address}` must be paths to
64
                    files in a single sources directory. Multiple directories
65
                    were found: {directory_prefixes}
66
                    """
67
                )
68
            )
69

70

71
class DebianSymlinks(DictStringToStringField):
×
72
    alias = "symlinks"
×
73
    help = help_text(
×
74
        """
75
        Symlinks to create for each target being packaged.
76

77
        For example, you could set symlinks={'command-name': 'entrypoint-name'}.
78
        """
79
    )
80

81

82
class DebianInstallPrefix(StringField):
×
83
    alias = "install_prefix"
×
84
    default = "/opt"
×
85
    help = "Absolute path to a directory where Debian package will be installed to."
×
86

87

88
class DebianPackageDependencies(SpecialCasedDependencies):
×
89
    alias = "packages"
×
90
    required = True
×
91
    help = help_text(
×
92
        f"""
93
        Addresses to any targets that can be built with `{bin_name()} package`, e.g.
94
        `["project:app"]`.
95

96
        Pants will build the assets as if you had run `{bin_name()} package`.
97
        It will include the results in your Debian package using the same name they would normally have,
98
        but without the `--distdir` prefix (e.g. `dist/`).
99

100
        You can include anything that can be built by `{bin_name()} package`, e.g. a `pex_binary`,
101
        a `python_distribution`, or an `archive`.
102
        """
103
    )
104

105

106
class DebianPackage(Target):
×
107
    alias = "debian_package"
×
108
    core_fields = (
×
109
        *COMMON_TARGET_FIELDS,
110
        OutputPathField,
111
        DebianSources,
112
        DebianSymlinks,
113
        DebianInstallPrefix,
114
        DebianPackageDependencies,
115
    )
116
    help = help_text(
×
117
        f"""
118
        A Debian package containing an artifact.
119

120
        This will not install the package, only create a `.deb` file
121
        that you can then distribute and install, e.g. via `dpkg`.
122

123
        See {doc_url("reference/targets/debian_package")}.
124
        """
125
    )
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