Skip to content

Commit

Permalink
Deprecate plugin targets not having Target API bindings (pantsbuild#9896
Browse files Browse the repository at this point in the history
)

Refer to https://groups.google.com/forum/#!topic/pants-devel/WsRFODRLVZI.

We put the deprecation in the `transitive_hydrated_targets` rule because this gets executed every single V1 run and shouldn't be executed more than once in V1 code paths.

[ci skip-rust-tests]
[ci skip-jvm-tests]
  • Loading branch information
Eric-Arellano authored May 29, 2020
1 parent 6addb3f commit d70bac1
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/python/pants/engine/legacy/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from dataclasses import dataclass
from typing import Any, Dict, Iterable, Iterator, List, Set, Tuple, Type, cast

from pants.base.deprecated import deprecated_conditional
from pants.base.exceptions import TargetDefinitionException
from pants.base.parse_context import ParseContext
from pants.base.specs import AddressSpec, AddressSpecs, SingleAddress
Expand All @@ -31,6 +32,7 @@
)
from pants.engine.rules import rule
from pants.engine.selectors import Get, MultiGet
from pants.engine.target import RegisteredTargetTypes
from pants.option.global_options import GlobMatchErrorBehavior
from pants.source.wrapped_globs import EagerFilesetWithSpec, FilesetRelPathWrapper, Filespec
from pants.util.meta import frozen_after_init
Expand Down Expand Up @@ -422,7 +424,9 @@ class LegacyTransitiveHydratedTargets:


@rule
async def transitive_hydrated_targets(addresses: Addresses) -> TransitiveHydratedTargets:
async def transitive_hydrated_targets(
addresses: Addresses, registered_target_types: RegisteredTargetTypes
) -> TransitiveHydratedTargets:
"""Given Addresses, kicks off recursion on expansion of TransitiveHydratedTargets.
The TransitiveHydratedTarget struct represents a structure-shared graph, which we walk and
Expand All @@ -445,6 +449,25 @@ async def transitive_hydrated_targets(addresses: Addresses) -> TransitiveHydrate
closure.add(tht.root)
to_visit.extend(tht.dependencies)

no_target_api_bindings = {
ht.adaptor.type_alias
for ht in closure
if ht.adaptor.type_alias not in registered_target_types.aliases
}
deprecated_conditional(
predicate=lambda: bool(no_target_api_bindings),
removal_version="1.30.0.dev0",
entity_description="Custom V1 targets not having a Target API binding",
hint_message=(
"You have some custom target types that will soon need light-weight bindings for the "
"new and more powerful Target API to continue working properly with parts of Pants, "
"like the `list` and `filedeps` goals.\n\nSee "
"https://groups.google.com/forum/#!topic/pants-devel/WsRFODRLVZI for more information "
f"and instructions.\n\n(Could not find bindings for: {sorted(no_target_api_bindings)})"
),
stacklevel=4,
)

return TransitiveHydratedTargets(
tuple(tht.root for tht in transitive_hydrated_targets), FrozenOrderedSet(closure)
)
Expand Down

0 comments on commit d70bac1

Please sign in to comment.