-
-
Notifications
You must be signed in to change notification settings - Fork 617
/
deprecated_v1_target_types.py
196 lines (143 loc) · 5.76 KB
/
deprecated_v1_target_types.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
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."
)