-
-
Notifications
You must be signed in to change notification settings - Fork 645
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
Restore several removed targets and fields to help with upgrading #10970
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from typing import Iterable, Optional | ||
|
||
from pants.backend.python.target_types import COMMON_PYTHON_FIELDS, PythonInterpreterCompatibility | ||
from pants.engine.addresses import Address | ||
from pants.engine.target import ( | ||
COMMON_TARGET_FIELDS, | ||
BoolField, | ||
Dependencies, | ||
InvalidFieldException, | ||
SequenceField, | ||
Sources, | ||
StringField, | ||
StringSequenceField, | ||
Target, | ||
) | ||
|
||
# ----------------------------------------------------------------------------------------------- | ||
# `alias` target | ||
# ----------------------------------------------------------------------------------------------- | ||
|
||
|
||
class AliasTargetRequestedAddress(StringField): | ||
alias = "target" | ||
|
||
|
||
class AliasTarget(Target): | ||
alias = "alias" | ||
core_fields = (*COMMON_TARGET_FIELDS, Dependencies, AliasTargetRequestedAddress) | ||
deprecated_removal_version = "2.1.0.dev0" | ||
deprecated_removal_hint = ( | ||
"The `alias` target was removed. If you found this feature useful, we'd be happy to add it" | ||
"back in a more powerful way. Please message us on Slack or open a GitHub issue " | ||
"(https://www.pantsbuild.org/docs/community)." | ||
) | ||
|
||
|
||
# ----------------------------------------------------------------------------------------------- | ||
# `prep_command` target | ||
# ----------------------------------------------------------------------------------------------- | ||
|
||
|
||
class PrepCommandExecutable(StringField): | ||
alias = "prep_executable" | ||
required = True | ||
|
||
|
||
class PrepCommandArgs(StringSequenceField): | ||
alias = "prep_args" | ||
|
||
|
||
class PrepCommandEnviron(BoolField): | ||
alias = "prep_environ" | ||
default = False | ||
|
||
|
||
class PrepCommandGoals(StringSequenceField): | ||
alias = "goals" | ||
default = ("test",) | ||
|
||
|
||
class PrepCommand(Target): | ||
alias = "prep_command" | ||
core_fields = ( | ||
*COMMON_TARGET_FIELDS, | ||
PrepCommandExecutable, | ||
PrepCommandArgs, | ||
PrepCommandEnviron, | ||
PrepCommandGoals, | ||
) | ||
deprecated_removal_version = "2.1.0.dev0" | ||
deprecated_removal_hint = ( | ||
"The `prep_command` target was removed, as it does not fit well with the v2 engine's " | ||
"execution model. If you needed this functionality, please message us on Slack " | ||
"(https://www.pantsbuild.org/docs/community) and we will help to recreate your setup." | ||
) | ||
|
||
|
||
# ----------------------------------------------------------------------------------------------- | ||
# `python_app` target | ||
# ----------------------------------------------------------------------------------------------- | ||
|
||
|
||
class PythonAppBinaryField(StringField): | ||
alias = "binary" | ||
|
||
|
||
class PythonAppBasename(StringField): | ||
alias = "basename" | ||
|
||
|
||
class PythonAppArchiveFormat(StringField): | ||
alias = "archive" | ||
|
||
|
||
class Bundle: | ||
def __init__(self, parse_context): | ||
self._parse_context = parse_context | ||
|
||
def __call__(self, rel_path=None, mapper=None, relative_to=None, fileset=None): | ||
pass | ||
|
||
|
||
class BundlesField(SequenceField): | ||
alias = "bundles" | ||
expected_element_type = Bundle | ||
expected_type_description = "an iterable of `bundle` objects" | ||
|
||
@classmethod | ||
def compute_value(cls, raw_value: Optional[Iterable[Bundle]], *, address: Address) -> None: | ||
try: | ||
super().compute_value(raw_value, address=address) | ||
except InvalidFieldException: | ||
pass | ||
return None | ||
|
||
|
||
class PythonApp(Target): | ||
alias = "python_app" | ||
core_fields = ( | ||
*COMMON_TARGET_FIELDS, | ||
Dependencies, | ||
BundlesField, | ||
PythonAppBinaryField, | ||
PythonAppBasename, | ||
PythonAppArchiveFormat, | ||
) | ||
deprecated_removal_version = "2.1.0.dev0" | ||
deprecated_removal_hint = ( | ||
"Instead of `python_app`, use the simpler `archive` target. If you still need to relocate " | ||
"files, use the new `relocated_files` target. See " | ||
"https://www.pantsbuild.org/docs/resources." | ||
) | ||
|
||
|
||
# ----------------------------------------------------------------------------------------------- | ||
# `unpacked_wheels` target | ||
# ----------------------------------------------------------------------------------------------- | ||
|
||
|
||
class UnpackedWheelsModuleName(StringField): | ||
alias = "module_name" | ||
required = True | ||
|
||
|
||
class UnpackedWheelsRequestedLibraries(StringSequenceField): | ||
alias = "libraries" | ||
required = True | ||
|
||
|
||
class UnpackedWheelsIncludePatterns(StringSequenceField): | ||
alias = "include_patterns" | ||
|
||
|
||
class UnpackedWheelsExcludePatterns(StringSequenceField): | ||
alias = "exclude_patterns" | ||
|
||
|
||
class UnpackedWheelsWithinDataSubdir(BoolField): | ||
alias = "within_data_subdir" | ||
default = False | ||
|
||
|
||
class UnpackedWheels(Target): | ||
alias = "unpacked_whls" | ||
core_fields = ( | ||
*COMMON_TARGET_FIELDS, | ||
PythonInterpreterCompatibility, | ||
UnpackedWheelsModuleName, | ||
UnpackedWheelsRequestedLibraries, | ||
UnpackedWheelsIncludePatterns, | ||
UnpackedWheelsExcludePatterns, | ||
UnpackedWheelsWithinDataSubdir, | ||
) | ||
deprecated_removal_version = "2.1.0.dev0" | ||
deprecated_removal_hint = ( | ||
"The `unpacked_wheels` target type was removed. Please reach out if you'd still like this " | ||
"functionality (https://www.pantsbuild.org/docs/community)." | ||
) | ||
|
||
|
||
# ----------------------------------------------------------------------------------------------- | ||
# `python_grpcio_library` target | ||
# ----------------------------------------------------------------------------------------------- | ||
|
||
|
||
class PythonGrpcioLibrary(Target): | ||
alias = "python_grpcio_library" | ||
core_fields = (*COMMON_PYTHON_FIELDS, Dependencies, Sources) | ||
deprecated_removal_version = "2.1.0.dev0" | ||
deprecated_removal_hint = ( | ||
"Instead of `python_grpcio_library`, use `protobuf_library(grpc=True)`. See " | ||
"https://www.pantsbuild.org/docs/protobuf." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use contextlib.suppress
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, good point. This code is only being added to 2.0.0, though, in a hackily named
deprecated_v1_target_types.py
file, so I'm not gonna worry about it.Good to know for the future, though.