If I want to upload a file to an endpoint (like a ...
# plugins
q
If I want to upload a file to an endpoint (like a package to an artifactory) in a custom plugin, is using
Process
with
curl
the best way? Or is there another, preferred way to do it using the Rules API?
g
I'm not aware of any method to do that using the rules API, and it seems like a good use-case for a process, as rule evaluation should try to stay cheap. Otherwise you could of course use something like urllib/requests.
q
How does the publish built-in goal publish wheels? Does it internally use Process as well?
n
I believe Pants uses https://pypi.org/project/twine/ to publish wheels.
q
Oh I see. Thank you!
g
To be exact, it builds a pex with twine, and then executes that in a process.
q
I see. But what about the
publish
goal? How does that publish artifacts to a artifactory?
g
It depends on the "implementation" of the goal for a specific target/language. For Python, it's as I described. For my OCI plugin, I use skopeo. Other backends will use their own tool.
pants publish
isn't a specific codepath, it finds rules that accept the specified target(s) and delegates to that rule to do the lifting. See this code here, which is porcelain side of the equation: https://github.com/pantsbuild/pants/blob/main/src/python/pants/core/goals/publish.py#L219-L273 - it gathers a number of process-objects (i.e., not launched) for all possible targets, then handles one at a time to do the actual publishing. The plumbing side is here: https://github.com/pantsbuild/pants/blob/main/src/python/pants/backend/python/goals/publish.py#L134. You can see it returns a specific "PublishProcess", which is mostly a process with metadata.