Skip to content

Commit

Permalink
Merge f9ac86c into 7f76dbc
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Arellano committed Sep 9, 2020
2 parents 7f76dbc + f9ac86c commit d5cba5b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/python/pants/backend/python/goals/pytest_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from dataclasses import dataclass
from pathlib import PurePath
from typing import Optional, cast
from uuid import UUID

from pants.backend.python.goals.coverage_py import (
CoverageConfig,
Expand Down Expand Up @@ -42,7 +41,7 @@
from pants.core.util_rules.source_files import SourceFiles, SourceFilesRequest
from pants.engine.addresses import Addresses
from pants.engine.fs import AddPrefix, Digest, DigestSubset, MergeDigests, PathGlobs, Snapshot
from pants.engine.internals.uuid import UUIDRequest
from pants.engine.internals.uuid import UUID, UUIDRequest
from pants.engine.process import FallibleProcessResult, InteractiveProcess, Process
from pants.engine.rules import Get, MultiGet, collect_rules, rule
from pants.engine.target import FieldSetsPerTarget, FieldSetsPerTargetRequest, TransitiveTargets
Expand Down
3 changes: 2 additions & 1 deletion src/python/pants/engine/internals/uuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import random
import uuid
from dataclasses import dataclass, field
from uuid import UUID as UUID

from pants.engine.rules import _uncacheable_rule, collect_rules

Expand All @@ -14,7 +15,7 @@ class UUIDRequest:


@_uncacheable_rule
async def generate_uuid(_: UUIDRequest) -> uuid.UUID:
async def generate_uuid(_: UUIDRequest) -> UUID:
"""A rule to generate a UUID.
Useful primarily to force a rule to re-run: a rule that `await Get`s on a UUIDRequest will be
Expand Down
4 changes: 1 addition & 3 deletions src/python/pants/engine/internals/uuid_test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from uuid import UUID

import pytest

from pants.engine.internals.uuid import UUIDRequest
from pants.engine.internals.uuid import UUID, UUIDRequest
from pants.engine.internals.uuid import rules as uuid_rules
from pants.engine.rules import QueryRule
from pants.testutil.rule_runner import RuleRunner
Expand Down
17 changes: 12 additions & 5 deletions src/python/pants/engine/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
from pants.base.exception_sink import ExceptionSink
from pants.engine.engine_aware import EngineAwareReturnType
from pants.engine.fs import EMPTY_DIGEST, CreateDigest, Digest, FileContent
from pants.engine.internals.uuid import UUID, UUIDRequest
from pants.engine.platform import Platform, PlatformConstraint
from pants.engine.rules import Get, collect_rules, rule, side_effecting
from pants.engine.rules import Get, MultiGet, collect_rules, rule, side_effecting
from pants.util.frozendict import FrozenDict
from pants.util.logging import LogLevel
from pants.util.meta import frozen_after_init
Expand Down Expand Up @@ -367,9 +368,15 @@ async def find_binary(request: BinaryPathRequest) -> BinaryPaths:
fi
"""
)
script_digest = await Get(
Digest,
CreateDigest([FileContent(script_path, script_content.encode(), is_executable=True)]),

# We get a UUID so that we ignore the cache every time, as this script depends on the state of
# the external environment.
script_digest, uuid = await MultiGet(
Get(
Digest,
CreateDigest([FileContent(script_path, script_content.encode(), is_executable=True)]),
),
Get(UUID, UUIDRequest()),
)

paths = []
Expand All @@ -381,7 +388,7 @@ async def find_binary(request: BinaryPathRequest) -> BinaryPaths:
level=LogLevel.DEBUG,
input_digest=script_digest,
argv=[script_path, request.binary_name],
env={"PATH": search_path},
env={"PATH": search_path, "__PANTS_UUID__": str(uuid)},
),
)
if result.exit_code == 0:
Expand Down

0 comments on commit d5cba5b

Please sign in to comment.