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

pantsbuild / pants / 22360764254

24 Feb 2026 04:46PM UTC coverage: 88.798% (-4.1%) from 92.935%
22360764254

Pull #23133

github

web-flow
Merge 4c056364c into 4d038bd74
Pull Request #23133: Add buildctl engine

181 of 264 new or added lines in 8 files covered. (68.56%)

3184 existing lines in 145 files now uncovered.

77555 of 87339 relevant lines covered (88.8%)

3.34 hits per line

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

75.0
/src/python/pants/backend/python/subsystems/setup_py_generation.py
1
# Copyright 2023 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3
import enum
6✔
4

5
from pants.option.option_types import BoolOption, EnumOption
6✔
6
from pants.option.subsystem import Subsystem
6✔
7
from pants.util.strutil import softwrap
6✔
8

9

10
@enum.unique
6✔
11
class FirstPartyDependencyVersionScheme(enum.Enum):
6✔
12
    EXACT = "exact"  # i.e., ==
6✔
13
    COMPATIBLE = "compatible"  # i.e., ~=
6✔
14
    ANY = "any"  # i.e., no specifier
6✔
15

16

17
class SetupPyGeneration(Subsystem):
6✔
18
    options_scope = "setup-py-generation"
6✔
19
    help = "Options to control how setup.py is generated from a `python_distribution` target."
6✔
20

21
    # Generating setup is the more aggressive thing to do, so we'd prefer that the default
22
    # be False. However that would break widespread existing usage, so we'll make that
23
    # change in a future deprecation cycle.
24
    generate_setup_default = BoolOption(
6✔
25
        default=True,
26
        help=softwrap(
27
            """
28
            The default value for the `generate_setup` field on `python_distribution` targets.
29
            Can be overridden per-target by setting that field explicitly. Set this to False
30
            if you mostly rely on handwritten setup files (`setup.py`, `setup.cfg` and similar).
31
            Leave as True if you mostly rely on Pants generating setup files for you.
32
            """
33
        ),
34
    )
35

36
    first_party_dependency_version_scheme = EnumOption(
6✔
37
        default=FirstPartyDependencyVersionScheme.EXACT,
38
        help=softwrap(
39
            """
40
            What version to set in `install_requires` when a `python_distribution` depends on
41
            other `python_distribution`s. If `exact`, will use `==`. If `compatible`, will
42
            use `~=`. If `any`, will leave off the version. See
43
            https://www.python.org/dev/peps/pep-0440/#version-specifiers.
44
            """
45
        ),
46
    )
47

48
    def first_party_dependency_version(self, version: str) -> str:
6✔
49
        """Return the version string (e.g. '~=4.0') for a first-party dependency.
50

51
        If the user specified to use "any" version, then this will return an empty string.
52
        """
UNCOV
53
        scheme = self.first_party_dependency_version_scheme
×
UNCOV
54
        if scheme == FirstPartyDependencyVersionScheme.ANY:
×
UNCOV
55
            return ""
×
UNCOV
56
        specifier = "==" if scheme == FirstPartyDependencyVersionScheme.EXACT else "~="
×
UNCOV
57
        return f"{specifier}{version}"
×
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