Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[internal] Make generate-lockfiles goal generic #14122

Merged
merged 7 commits into from
Jan 11, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
from typing import cast

from pants.backend.codegen.protobuf.target_types import ProtobufDependenciesField
from pants.backend.python.goals.lockfile import PythonLockfileRequest, PythonToolLockfileSentinel
from pants.backend.python.goals.lockfile import PythonLockfileRequest
from pants.backend.python.subsystems.python_tool_base import PythonToolRequirementsBase
from pants.core.goals.generate_lockfiles import ToolLockfileSentinel
from pants.engine.addresses import Addresses, UnparsedAddressInputs
from pants.engine.rules import Get, collect_rules, rule
from pants.engine.target import InjectDependenciesRequest, InjectedDependencies
Expand Down Expand Up @@ -72,7 +73,7 @@ class PythonProtobufMypyPlugin(PythonToolRequirementsBase):
default_lockfile_url = git_url(default_lockfile_path)


class MypyProtobufLockfileSentinel(PythonToolLockfileSentinel):
class MypyProtobufLockfileSentinel(ToolLockfileSentinel):
options_scope = PythonProtobufMypyPlugin.options_scope


Expand All @@ -99,5 +100,5 @@ def rules():
return [
*collect_rules(),
UnionRule(InjectDependenciesRequest, InjectPythonProtobufDependencies),
UnionRule(PythonToolLockfileSentinel, MypyProtobufLockfileSentinel),
UnionRule(ToolLockfileSentinel, MypyProtobufLockfileSentinel),
]
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@

from pants.backend.docker.target_types import DockerImageSourceField
from pants.backend.docker.util_rules.docker_build_args import DockerBuildArgs
from pants.backend.python.goals.lockfile import PythonLockfileRequest, PythonToolLockfileSentinel
from pants.backend.python.goals.lockfile import PythonLockfileRequest
from pants.backend.python.subsystems.python_tool_base import PythonToolRequirementsBase
from pants.backend.python.target_types import EntryPoint
from pants.backend.python.util_rules.pex import PexRequest, VenvPex, VenvPexProcess
from pants.core.goals.generate_lockfiles import ToolLockfileSentinel
from pants.engine.addresses import Address
from pants.engine.fs import CreateDigest, Digest, FileContent
from pants.engine.process import Process, ProcessResult
Expand Down Expand Up @@ -44,7 +45,7 @@ class DockerfileParser(PythonToolRequirementsBase):
default_lockfile_url = git_url(default_lockfile_path)


class DockerfileParserLockfileSentinel(PythonToolLockfileSentinel):
class DockerfileParserLockfileSentinel(ToolLockfileSentinel):
options_scope = DockerfileParser.options_scope


Expand Down Expand Up @@ -198,5 +199,5 @@ async def parse_dockerfile(request: DockerfileInfoRequest) -> DockerfileInfo:
def rules():
return (
*collect_rules(),
UnionRule(PythonToolLockfileSentinel, DockerfileParserLockfileSentinel),
UnionRule(ToolLockfileSentinel, DockerfileParserLockfileSentinel),
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@

import logging

from pants.backend.python.goals.lockfile import PythonLockfile, PythonLockfileRequest
from pants.backend.python.goals.lockfile import PythonLockfileRequest
from pants.backend.python.subsystems.setup import PythonSetup
from pants.backend.python.target_types import PythonRequirementsField
from pants.backend.python.util_rules.interpreter_constraints import InterpreterConstraints
from pants.backend.python.util_rules.pex import PexRequirements
from pants.core.goals.generate_lockfiles import Lockfile
from pants.engine.addresses import Addresses
from pants.engine.fs import Workspace
from pants.engine.goal import Goal, GoalSubsystem
Expand Down Expand Up @@ -65,11 +66,11 @@ async def generate_user_lockfile_goal(
return GenerateUserLockfileGoal(exit_code=0)

result = await Get(
PythonLockfile,
Lockfile,
PythonLockfileRequest(
req_strings,
requirements=req_strings,
# TODO(#12314): Use interpreter constraints from the transitive closure.
InterpreterConstraints(python_setup.interpreter_constraints),
interpreter_constraints=InterpreterConstraints(python_setup.interpreter_constraints),
resolve_name="not yet implemented",
lockfile_dest=python_setup.lockfile,
_description=(
Expand Down
7 changes: 4 additions & 3 deletions src/python/pants/backend/python/goals/coverage_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@

import toml

from pants.backend.python.goals.lockfile import PythonLockfileRequest, PythonToolLockfileSentinel
from pants.backend.python.goals.lockfile import PythonLockfileRequest
from pants.backend.python.subsystems.python_tool_base import PythonToolBase
from pants.backend.python.target_types import ConsoleScript
from pants.backend.python.util_rules.pex import PexRequest, VenvPex, VenvPexProcess
from pants.backend.python.util_rules.python_sources import (
PythonSourceFiles,
PythonSourceFilesRequest,
)
from pants.core.goals.generate_lockfiles import ToolLockfileSentinel
from pants.core.goals.test import (
ConsoleCoverageReport,
CoverageData,
Expand Down Expand Up @@ -234,7 +235,7 @@ def fail_under(self) -> int:
return cast(int, self.options.fail_under)


class CoveragePyLockfileSentinel(PythonToolLockfileSentinel):
class CoveragePyLockfileSentinel(ToolLockfileSentinel):
options_scope = CoverageSubsystem.options_scope


Expand Down Expand Up @@ -607,5 +608,5 @@ def rules():
return [
*collect_rules(),
UnionRule(CoverageDataCollection, PytestCoverageDataCollection),
UnionRule(PythonToolLockfileSentinel, CoveragePyLockfileSentinel),
UnionRule(ToolLockfileSentinel, CoveragePyLockfileSentinel),
]
Loading