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

pantsbuild / pants / 19529437518

20 Nov 2025 07:44AM UTC coverage: 78.884% (-1.4%) from 80.302%
19529437518

push

github

web-flow
nfpm.native_libs: Add RPM package depends from packaged pex_binaries (#22899)

## PR Series Overview

This is the second in a series of PRs that introduces a new backend:
`pants.backend.npm.native_libs`
Initially, the backend will be available as:
`pants.backend.experimental.nfpm.native_libs`

I proposed this new backend (originally named `bindeps`) in discussion
#22396.

This backend will inspect ELF bin/lib files (like `lib*.so`) in packaged
contents (for this PR series, only in `pex_binary` targets) to identify
package dependency metadata and inject that metadata on the relevant
`nfpm_deb_package` or `nfpm_rpm_package` targets. Effectively, it will
provide an approximation of these native packager features:
- `rpm`: `rpmdeps` + `elfdeps`
- `deb`: `dh_shlibdeps` + `dpkg-shlibdeps` (These substitute
`${shlibs:Depends}` in debian control files have)

### Goal: Host-agnostic package builds

This pants backend is designed to be host-agnostic, like
[nFPM](https://nfpm.goreleaser.com/).

Native packaging tools are often restricted to a single release of a
single distro. Unlike native package builders, this new pants backend
does not use any of those distro-specific or distro-release-specific
utilities or local package databases. This new backend should be able to
run (help with building deb and rpm packages) anywhere that pants can
run (MacOS, rpm linux distros, deb linux distros, other linux distros,
docker, ...).

### Previous PRs in series

- #22873

## PR Overview

This PR adds rules in `nfpm.native_libs` to add package dependency
metadata to `nfpm_rpm_package`. The 2 new rules are:

- `inject_native_libs_dependencies_in_package_fields`:

    - An implementation of the polymorphic rule `inject_nfpm_package_fields`.
      This rule is low priority (`priority = 2`) so that in-repo plugins can
      override/augment what it injects. (See #22864)

    - Rule logic overview:
        - find any pex_binaries that will be packaged in an `nfpm_rpm_package`
   ... (continued)

96 of 118 new or added lines in 3 files covered. (81.36%)

910 existing lines in 53 files now uncovered.

73897 of 93678 relevant lines covered (78.88%)

3.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/python/pants/backend/k8s/k8s_subsystem.py
1
# Copyright 2024 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
UNCOV
3
import logging
×
4

UNCOV
5
from pants.engine.rules import collect_rules
×
UNCOV
6
from pants.option.option_types import BoolOption, StrListOption
×
UNCOV
7
from pants.option.subsystem import Subsystem
×
UNCOV
8
from pants.util.strutil import softwrap
×
9

UNCOV
10
logger = logging.getLogger(__name__)
×
11

12

UNCOV
13
class K8sSubsystem(Subsystem):
×
UNCOV
14
    name = "k8s"
×
UNCOV
15
    options_scope = "k8s"
×
UNCOV
16
    help = "Kubernetes options"
×
17

UNCOV
18
    available_contexts = StrListOption(
×
19
        default=[],
20
        help=softwrap(
21
            """
22
            List of available contexts for `kubectl` command. `k8s_bundle`
23
            context will be validated against this list.
24

25
            You have to explicitly provide the list, because it will be shared
26
            with people using the pants repo. We can't parse the KUBECONFIG env
27
            var because different people might have different private clusters,
28
            e.g. minikube or kind, which means pants validation will give
29
            different results.
30
            """
31
        ),
32
    )
33

UNCOV
34
    tailor_source_targets = BoolOption(
×
35
        default=True,
36
        help=softwrap(
37
            """
38
            If true, add `k8s_sources` targets with the `tailor` goal.
39
            """
40
        ),
41
        advanced=True,
42
    )
43

44

UNCOV
45
def rules():
×
UNCOV
46
    return collect_rules()
×
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