narrow-activity-17405
08/31/2020, 8:02 AMnarrow-activity-17405
08/31/2020, 12:45 PMhundreds-father-404
08/31/2020, 5:10 PMhappy-kitchen-89482
09/01/2020, 4:25 AMhappy-kitchen-89482
09/01/2020, 4:26 AMnarrow-activity-17405
09/01/2020, 7:29 AMnarrow-activity-17405
09/01/2020, 7:30 AMhappy-kitchen-89482
09/01/2020, 9:32 PMpython_distribution target to a resource target that owns the VERSION file, so that invalidation happens when the VERSION file changes.hundreds-father-404
09/02/2020, 7:16 AMhundreds-father-404
09/04/2020, 6:39 PMsetup-py kwargs. It includes an example that does exactly what you’re trying to do.
Start with this guide to upgrade to 2.0: https://www.pantsbuild.org/v2.0/docs/how-to-upgrade-pants-2-0
Then read https://www.pantsbuild.org/v2.0/docs/plugins-overview for an overview of how the Plugin API works, including its link to the concepts for the Rules API. Then, you can follow https://www.pantsbuild.org/v2.0/docs/plugins-setup-py-goal for a guide on setup-py. Let us know how we can help with this! Those docs are fairly new and not very battle tested, so any feedback is appreciatednarrow-activity-17405
09/07/2020, 2:06 PMnarrow-activity-17405
09/07/2020, 2:07 PM@rule
def setup_kwargs_plugin(request: CustomSetupKwargsRequest) -> SetupKwargs:
...should be
@rule
async def setup_kwargs_plugin(request: CustomSetupKwargsRequest) -> SetupKwargs:
Otherwise docs seems to be ok.hundreds-father-404
09/07/2020, 2:44 PMnarrow-activity-17405
09/11/2020, 10:02 AMnarrow-activity-17405
09/11/2020, 10:04 AMpython_distribution(
name="arcor2_execution_dist",
dependencies=[
":arcor2_execution",
":py.typed"
],
provides=arcor2_setup_py(
name="arcor2_execution",
description="ARCOR2 - Augmented Reality Collaborative Robot."
).with_binaries(
{
"arcor2_execution": "src/python/arcor2_execution/scripts:execution"
}
)
)
As a temporary solution I used
package_name = remove_suffix(request.target.address.target_name, "_dist")
...but there has to be better way 🙂narrow-activity-17405
09/11/2020, 10:07 AMhundreds-father-404
09/11/2020, 5:06 PMBtw, is there a way how can I get name of setup_py target?Yes, sorry, this is one of the remaining parts I need to document. So,
request.target is a Target, which stores a bunch of fields like the provides field. You want to access the provides field. To do that, write request.target[PythonProvidesField], where PythonProvidesField is imported from pants.backend.python.target_types. This will give you back a Field (capitalized), which has the properties .alias and .value. You want .value, to get the actual value the user gave.
The value for a PythonProvidesField is a little more complex than normal. Typically, `Field`s store primitives like str and int. For this one, it stores a PythonArtifact object, which has a property .name.
So, in full, you’ll do request.target[PythonProvidesField].value.namehundreds-father-404
09/11/2020, 5:07 PMI was missing most was links to API referencesAgreed that would be nice. We have hand-written references for some things like filesystem operations, but indeed nothing generated. For now, the alternative is to go to the definition in source code, e.g. if your editor lets you jump to the definition. We try to write good docstring, and we zealously use type hints
hundreds-father-404
09/12/2020, 3:52 AMnarrow-activity-17405
11/04/2020, 8:43 AM