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

Stop fetching a lockfile request just to figure out the requirements digest #12607

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/python/pants/backend/awslambda/python/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
import logging
from dataclasses import dataclass

from pants.backend.awslambda.python.lambdex import Lambdex, LambdexLockfileSentinel
from pants.backend.awslambda.python.lambdex import Lambdex
from pants.backend.awslambda.python.target_types import (
PythonAwsLambdaHandlerField,
PythonAwsLambdaRuntime,
ResolvedPythonAwsHandler,
ResolvePythonAwsHandlerRequest,
)
from pants.backend.experimental.python.lockfile import PythonLockfileRequest
from pants.backend.python.util_rules import pex_from_targets
from pants.backend.python.util_rules.pex import (
Pex,
Expand Down Expand Up @@ -87,15 +86,10 @@ async def package_python_awslambda(
],
)

lockfile_hex_digest = None
if lambdex.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, LambdexLockfileSentinel())
lockfile_hex_digest = lockfile_request.requirements_hex_digest

lambdex_request = PexRequest(
output_filename="lambdex.pex",
internal_only=True,
requirements=lambdex.pex_requirements(lockfile_hex_digest),
requirements=lambdex.pex_requirements(),
interpreter_constraints=lambdex.interpreter_constraints,
main=lambdex.main,
)
Expand Down
9 changes: 1 addition & 8 deletions src/python/pants/backend/codegen/protobuf/python/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
from pants.backend.codegen.protobuf.python.additional_fields import PythonSourceRootField
from pants.backend.codegen.protobuf.python.grpc_python_plugin import GrpcPythonPlugin
from pants.backend.codegen.protobuf.python.python_protobuf_subsystem import (
MypyProtobufLockfileSentinel,
PythonProtobufMypyPlugin,
PythonProtobufSubsystem,
)
from pants.backend.codegen.protobuf.target_types import ProtobufGrpcToggle, ProtobufSources
from pants.backend.experimental.python.lockfile import PythonLockfileRequest
from pants.backend.python.target_types import PythonSources
from pants.backend.python.util_rules import pex
from pants.backend.python.util_rules.pex import PexRequest, PexResolveInfo, VenvPex, VenvPexRequest
Expand Down Expand Up @@ -97,18 +95,13 @@ async def generate_python_from_protobuf(
target_stripped_sources_request,
)

lockfile_hex_digest = None
if python_protobuf_mypy_plugin.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, MypyProtobufLockfileSentinel())
lockfile_hex_digest = lockfile_request.requirements_hex_digest

protoc_gen_mypy_script = "protoc-gen-mypy"
protoc_gen_mypy_grpc_script = "protoc-gen-mypy_grpc"
mypy_pex = None
mypy_request = PexRequest(
output_filename="mypy_protobuf.pex",
internal_only=True,
requirements=python_protobuf_mypy_plugin.pex_requirements(lockfile_hex_digest),
requirements=python_protobuf_mypy_plugin.pex_requirements(),
interpreter_constraints=python_protobuf_mypy_plugin.interpreter_constraints,
)

Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/experimental/python/lockfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ async def generate_lockfile(
PexRequest(
output_filename="poetry.pex",
internal_only=True,
requirements=poetry_subsystem.pex_requirements(expected_lockfile_hex_digest=None),
requirements=poetry_subsystem.pex_requirements(),
interpreter_constraints=poetry_subsystem.interpreter_constraints,
main=EntryPoint(PurePath(POETRY_LAUNCHER.path).stem),
sources=launcher_digest,
Expand Down
7 changes: 1 addition & 6 deletions src/python/pants/backend/python/goals/coverage_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,17 +334,12 @@ class CoverageSetup:

@rule
async def setup_coverage(coverage: CoverageSubsystem) -> CoverageSetup:
lockfile_hex_digest = None
if coverage.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, CoveragePyLockfileSentinel())
lockfile_hex_digest = lockfile_request.requirements_hex_digest

pex = await Get(
VenvPex,
PexRequest(
output_filename="coverage.pex",
internal_only=True,
requirements=coverage.pex_requirements(lockfile_hex_digest),
requirements=coverage.pex_requirements(),
interpreter_constraints=coverage.interpreter_constraints,
main=coverage.main,
),
Expand Down
14 changes: 2 additions & 12 deletions src/python/pants/backend/python/goals/pytest_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@
from dataclasses import dataclass
from typing import Optional

from pants.backend.experimental.python.lockfile import PythonLockfileRequest
from pants.backend.python.goals.coverage_py import (
CoverageConfig,
CoverageSubsystem,
PytestCoverageData,
)
from pants.backend.python.subsystems.pytest import (
PyTest,
PytestLockfileSentinel,
PythonTestFieldSet,
)
from pants.backend.python.subsystems.pytest import PyTest, PythonTestFieldSet
from pants.backend.python.util_rules.interpreter_constraints import InterpreterConstraints
from pants.backend.python.util_rules.pex import Pex, PexRequest, VenvPex, VenvPexProcess
from pants.backend.python.util_rules.pex_from_targets import PexFromTargetsRequest
Expand Down Expand Up @@ -174,11 +169,6 @@ async def setup_pytest_for_target(

interpreter_constraints = InterpreterConstraints.create_from_targets(all_targets, python_setup)

lockfile_hex_digest = None
if pytest.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, PytestLockfileSentinel())
lockfile_hex_digest = lockfile_request.requirements_hex_digest

requirements_pex_get = Get(
Pex,
PexFromTargetsRequest,
Expand All @@ -188,7 +178,7 @@ async def setup_pytest_for_target(
Pex,
PexRequest(
output_filename="pytest.pex",
requirements=pytest.pex_requirements(lockfile_hex_digest),
requirements=pytest.pex_requirements(),
interpreter_constraints=interpreter_constraints,
internal_only=True,
),
Expand Down
10 changes: 2 additions & 8 deletions src/python/pants/backend/python/goals/repl.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from pants.backend.experimental.python.lockfile import PythonLockfileRequest
from pants.backend.python.subsystems.ipython import IPython, IPythonLockfileSentinel
from pants.backend.python.subsystems.ipython import IPython
from pants.backend.python.util_rules.pex import Pex, PexRequest
from pants.backend.python.util_rules.pex_environment import PexEnvironment
from pants.backend.python.util_rules.pex_from_targets import PexFromTargetsRequest
Expand Down Expand Up @@ -76,17 +75,12 @@ async def create_ipython_repl_request(
PythonSourceFiles, PythonSourceFilesRequest(repl.targets, include_files=True)
)

lockfile_hex_digest = None
if ipython.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, IPythonLockfileSentinel())
lockfile_hex_digest = lockfile_request.requirements_hex_digest

ipython_request = Get(
Pex,
PexRequest(
output_filename="ipython.pex",
main=ipython.main,
requirements=ipython.pex_requirements(lockfile_hex_digest),
requirements=ipython.pex_requirements(),
interpreter_constraints=requirements_pex_request.interpreter_constraints,
internal_only=True,
),
Expand Down
14 changes: 2 additions & 12 deletions src/python/pants/backend/python/goals/setup_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@
from functools import partial
from typing import Any, DefaultDict, Dict, List, Mapping, Set, Tuple, cast

from pants.backend.experimental.python.lockfile import PythonLockfileRequest
from pants.backend.python.macros.python_artifact import PythonArtifact
from pants.backend.python.subsystems.setuptools import (
PythonDistributionFieldSet,
Setuptools,
SetuptoolsLockfileSentinel,
)
from pants.backend.python.subsystems.setuptools import PythonDistributionFieldSet, Setuptools
from pants.backend.python.target_types import (
PythonDistributionEntryPointsField,
PythonProvidesField,
Expand Down Expand Up @@ -420,17 +415,12 @@ async def run_setup_py(req: RunSetupPyRequest, setuptools: Setuptools) -> RunSet
# Note that this pex has no entrypoint. We use it to run our generated setup.py, which
# in turn imports from and invokes setuptools.

lockfile_hex_digest = None
if setuptools.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, SetuptoolsLockfileSentinel())
lockfile_hex_digest = lockfile_request.requirements_hex_digest

setuptools_pex = await Get(
VenvPex,
PexRequest(
output_filename="setuptools.pex",
internal_only=True,
requirements=setuptools.pex_requirements(lockfile_hex_digest),
requirements=setuptools.pex_requirements(),
interpreter_constraints=req.interpreter_constraints,
),
)
Expand Down
13 changes: 2 additions & 11 deletions src/python/pants/backend/python/lint/bandit/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
from dataclasses import dataclass
from typing import Tuple

from pants.backend.experimental.python.lockfile import PythonLockfileRequest
from pants.backend.python.lint.bandit.subsystem import (
Bandit,
BanditFieldSet,
BanditLockfileSentinel,
)
from pants.backend.python.lint.bandit.subsystem import Bandit, BanditFieldSet
from pants.backend.python.util_rules import pex
from pants.backend.python.util_rules.interpreter_constraints import InterpreterConstraints
from pants.backend.python.util_rules.pex import PexRequest, VenvPex, VenvPexProcess
Expand Down Expand Up @@ -46,17 +41,13 @@ def generate_argv(source_files: SourceFiles, bandit: Bandit) -> Tuple[str, ...]:

@rule(level=LogLevel.DEBUG)
async def bandit_lint_partition(partition: BanditPartition, bandit: Bandit) -> LintResult:
lockfile_hex_digest = None
if bandit.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, BanditLockfileSentinel())
lockfile_hex_digest = lockfile_request.requirements_hex_digest

bandit_pex_get = Get(
VenvPex,
PexRequest(
output_filename="bandit.pex",
internal_only=True,
requirements=bandit.pex_requirements(lockfile_hex_digest),
requirements=bandit.pex_requirements(),
interpreter_constraints=partition.interpreter_constraints,
main=bandit.main,
),
Expand Down
10 changes: 2 additions & 8 deletions src/python/pants/backend/python/lint/black/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
from dataclasses import dataclass
from typing import Tuple

from pants.backend.experimental.python.lockfile import PythonLockfileRequest
from pants.backend.python.lint.black.skip_field import SkipBlackField
from pants.backend.python.lint.black.subsystem import Black, BlackLockfileSentinel
from pants.backend.python.lint.black.subsystem import Black
from pants.backend.python.lint.python_fmt import PythonFmtRequest
from pants.backend.python.target_types import InterpreterConstraintsField, PythonSources
from pants.backend.python.util_rules import pex
Expand Down Expand Up @@ -89,17 +88,12 @@ async def setup_black(
else black.interpreter_constraints
)

lockfile_hex_digest = None
if black.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, BlackLockfileSentinel())
lockfile_hex_digest = lockfile_request.requirements_hex_digest

black_pex_get = Get(
VenvPex,
PexRequest(
output_filename="black.pex",
internal_only=True,
requirements=black.pex_requirements(lockfile_hex_digest),
requirements=black.pex_requirements(),
interpreter_constraints=tool_interpreter_constraints,
main=black.main,
),
Expand Down
12 changes: 2 additions & 10 deletions src/python/pants/backend/python/lint/docformatter/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
from dataclasses import dataclass
from typing import Tuple

from pants.backend.experimental.python.lockfile import PythonLockfileRequest
from pants.backend.python.lint.docformatter.skip_field import SkipDocformatterField
from pants.backend.python.lint.docformatter.subsystem import (
Docformatter,
DocformatterLockfileSentinel,
)
from pants.backend.python.lint.docformatter.subsystem import Docformatter
from pants.backend.python.lint.python_fmt import PythonFmtRequest
from pants.backend.python.target_types import PythonSources
from pants.backend.python.util_rules import pex
Expand Down Expand Up @@ -61,17 +57,13 @@ def generate_args(

@rule(level=LogLevel.DEBUG)
async def setup_docformatter(setup_request: SetupRequest, docformatter: Docformatter) -> Setup:
lockfile_hex_digest = None
if docformatter.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, DocformatterLockfileSentinel())
lockfile_hex_digest = lockfile_request.requirements_hex_digest

docformatter_pex_get = Get(
VenvPex,
PexRequest(
output_filename="docformatter.pex",
internal_only=True,
requirements=docformatter.pex_requirements(lockfile_hex_digest),
requirements=docformatter.pex_requirements(),
interpreter_constraints=docformatter.interpreter_constraints,
main=docformatter.main,
),
Expand Down
14 changes: 2 additions & 12 deletions src/python/pants/backend/python/lint/flake8/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
from dataclasses import dataclass
from typing import Tuple

from pants.backend.experimental.python.lockfile import PythonLockfileRequest
from pants.backend.python.lint.flake8.subsystem import (
Flake8,
Flake8FieldSet,
Flake8LockfileSentinel,
)
from pants.backend.python.lint.flake8.subsystem import Flake8, Flake8FieldSet
from pants.backend.python.util_rules import pex
from pants.backend.python.util_rules.interpreter_constraints import InterpreterConstraints
from pants.backend.python.util_rules.pex import PexRequest, VenvPex, VenvPexProcess
Expand Down Expand Up @@ -46,17 +41,12 @@ def generate_argv(source_files: SourceFiles, flake8: Flake8) -> Tuple[str, ...]:

@rule(level=LogLevel.DEBUG)
async def flake8_lint_partition(partition: Flake8Partition, flake8: Flake8) -> LintResult:
lockfile_hex_digest = None
if flake8.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, Flake8LockfileSentinel())
lockfile_hex_digest = lockfile_request.requirements_hex_digest

flake8_pex_get = Get(
VenvPex,
PexRequest(
output_filename="flake8.pex",
internal_only=True,
requirements=flake8.pex_requirements(lockfile_hex_digest),
requirements=flake8.pex_requirements(),
interpreter_constraints=partition.interpreter_constraints,
main=flake8.main,
),
Expand Down
10 changes: 2 additions & 8 deletions src/python/pants/backend/python/lint/isort/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
from dataclasses import dataclass
from typing import Tuple

from pants.backend.experimental.python.lockfile import PythonLockfileRequest
from pants.backend.python.lint.isort.skip_field import SkipIsortField
from pants.backend.python.lint.isort.subsystem import Isort, IsortLockfileSentinel
from pants.backend.python.lint.isort.subsystem import Isort
from pants.backend.python.lint.python_fmt import PythonFmtRequest
from pants.backend.python.target_types import PythonSources
from pants.backend.python.util_rules import pex
Expand Down Expand Up @@ -78,17 +77,12 @@ def generate_argv(

@rule(level=LogLevel.DEBUG)
async def setup_isort(setup_request: SetupRequest, isort: Isort) -> Setup:
lockfile_hex_digest = None
if isort.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, IsortLockfileSentinel())
lockfile_hex_digest = lockfile_request.requirements_hex_digest

isort_pex_get = Get(
VenvPex,
PexRequest(
output_filename="isort.pex",
internal_only=True,
requirements=isort.pex_requirements(lockfile_hex_digest),
requirements=isort.pex_requirements(),
interpreter_constraints=isort.interpreter_constraints,
main=isort.main,
),
Expand Down
8 changes: 0 additions & 8 deletions src/python/pants/backend/python/lint/pylint/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
from dataclasses import dataclass
from typing import Iterable, List, Tuple

from pants.backend.experimental.python.lockfile import PythonLockfileRequest
from pants.backend.python.lint.pylint.subsystem import (
Pylint,
PylintFieldSet,
PylintFirstPartyPlugins,
PylintLockfileSentinel,
)
from pants.backend.python.target_types import InterpreterConstraintsField
from pants.backend.python.util_rules import pex_from_targets
Expand Down Expand Up @@ -82,11 +80,6 @@ def generate_argv(source_files: SourceFiles, pylint: Pylint) -> Tuple[str, ...]:
async def pylint_lint_partition(
partition: PylintPartition, pylint: Pylint, first_party_plugins: PylintFirstPartyPlugins
) -> LintResult:
lockfile_hex_digest = None
if pylint.lockfile != "<none>":
lockfile_request = await Get(PythonLockfileRequest, PylintLockfileSentinel())
lockfile_hex_digest = lockfile_request.requirements_hex_digest

requirements_pex_get = Get(
Pex,
PexFromTargetsRequest,
Expand All @@ -108,7 +101,6 @@ async def pylint_lint_partition(
internal_only=True,
requirements=pylint.pex_requirements(
extra_requirements=first_party_plugins.requirement_strings,
expected_lockfile_hex_digest=lockfile_hex_digest,
),
interpreter_constraints=partition.interpreter_constraints,
),
Expand Down
Loading