https://pantsbuild.org/ logo
b

bright-pilot-85305

11/18/2022, 11:27 PM
Hey I'm trying to make a plugin to get the version from git. I have a
@rule
that returns
SetupKwargs
. The problem I'm having is it doesn't look like I can run git in the project root when using a normal
Process
. But when using an
InteractiveProcess
I have to use
@goal_rule
which isn't compatible with
SetupKwargs
. How do I go about this?
c

curved-television-6568

11/18/2022, 11:43 PM
I’m not sure how this all works, but there’s a
vcs_version
target that interacts with git in order to extract information. Useful pieces to look at could be: https://github.com/pantsbuild/pants/blob/b4334427b07bd057034718d3b7b8ea013b9a9bf1/src/python/pants/backend/python/util_rules/vcs_versioning.py#L62 https://github.com/pantsbuild/pants/blob/main/src/python/pants/vcs/git.py as a start..
👍 1
b

bright-pilot-85305

11/19/2022, 3:18 AM
Thanks for pointing me to this code. This is way to complicated, especially for the amount of documentation available. I'm just gonna use
subprocess.run
.
c

curved-television-6568

11/19/2022, 12:19 PM
Please do leave comments in your code about the gotchas in that case (as this is not recommended), as it will not work if you ever start using remote execution for instance. 😉
🙏 1
b

bright-pilot-85305

11/20/2022, 3:49 PM
Thanks! Good to know.
👌 1
3 Views