Is it possible to use environments in custom plugi...
# plugins
b
Is it possible to use environments in custom plugins? There doesn’t seem to be an documentation and I am struggling to piece together what I would need to do from the pants source code. Currently getting a long list of rule graph errors when doing so
f
Yes there is a special
Get
syntax for changing other parameters active in the rule graph. The environment in effect is one of those other parameters. See https://github.com/pantsbuild/pants/blob/0e51584547e86dd2e8d6e89755c1458ee29883cb/src/python/pants/core/goals/test.py#L948-L954 for an example.
đź‘€ 1
Copy code
package = await Get(
        BuiltPackage, {request.field_set: PackageFieldSet, environment_name: EnvironmentName}
)
This form of
Get
basically asks the engine: "Find a conversion between
PackageFieldSet
and
BuiltPackage
and set the instance of
EnvironmntName
in the rule graph to be
environment_name
during that evaluation."
and that override is in effect for that "subgraph" of the rule graph
b
I think that helps. Thanks. I will try and piece this together