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

pantsbuild / pants / 23068140808

13 Mar 2026 07:56PM UTC coverage: 52.677% (-40.3%) from 92.932%
23068140808

Pull #23170

github

web-flow
Merge e8ca01cfa into f07276df6
Pull Request #23170: Debug reapi test cache misses

31687 of 60153 relevant lines covered (52.68%)

1.05 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
2✔
4

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

9

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

16

17
class SetupPyGeneration(Subsystem):
2✔
18
    options_scope = "setup-py-generation"
2✔
19
    help = "Options to control how setup.py is generated from a `python_distribution` target."
2✔
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(
2✔
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(
2✔
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:
2✔
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
        """
53
        scheme = self.first_party_dependency_version_scheme
×
54
        if scheme == FirstPartyDependencyVersionScheme.ANY:
×
55
            return ""
×
56
        specifier = "==" if scheme == FirstPartyDependencyVersionScheme.EXACT else "~="
×
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