Plugin upgrade guide
How to adjust for changes made to the Plugin API.
2.17
Deprecated some Request
types in favor of Get
with only one arg
For several APIs like pants.core.util_rules.system_binaries
, we had an eager and lazy version of the same API. You could do either of these two:
from pants.core.util_rules.system_binaries import ZipBinary, ZipBinaryRequest
from pants.engine.rules import Get, rule
class MyOutput:
pass
@rule
def my_rule(zip_binary: ZipBinary) -> MyOutput:
return MyOutput()
@rule
async def my_rule_lazy() -> MyOutput:
zip_binary = await Get(ZipBinary, ZipBinaryRequest())
return MyOutput()
The lazy API is useful, for example, when you only want to Get
that output type inside an if
branch.
We added syntax in 2.17 to now use Get(OutputType)
, whereas before you had to do Get(OutputType, OutputTypeRequest)
or (as of 2.15) Get(OutputType, {})
. So, these OutputTypeRequest
types are now redundant and deprecated in favor of simply using Get(OutputType)
.
EnvironmentBehavior.UNMIGRATED
is no longer available
Following the deprecation cycle in 2.15, all Goal
s need to set EnvironmentBehavior.LOCAL_ONLY
or EnvironmentBehavior.USES_ENVIRONMENTS
.
2.16
RunFieldSet
and TestRequest
now have a .rules()
method
These methods should be used to register your run/test plugins:
def rules():
return [
*MyRunFieldSetSubclass.rules(),
*MyTestRequestSubclass.rules(),
]
Additionally, these types now by-default register the implementations for the rules used for --debug
/--debug-adapter
. If your plugin doesn't support these flags, simply remove the rules you've declared and let the default ones handle erroring. If your plugin does support these, set the class property(s) supports_debug = True
/supports_debug_adapter = True
, respectively.