Hello, everyone. I'm working on getting some tooli...
# plugins
w
Hello, everyone. I'm working on getting some tooling in place for building python applications and packaging them into docker. Can someone point me to some documentation or code examples on how, if possible, information between two targets gets shared when you leverage them as a dependency? Or some other way one could create a plugin to generate a string and make it available to other targets?
w
Can you show some code as to what you're trying to do? Like, you have a source target, that's a dep for another target - and the dep isn't available to the new target?
w
I don't have any workable code yet. Mostly I'm working on familiarize myself with the Pants code. The few examples I've seen (For example, pre-populating the
url
kwarg entry when using
setup_py()
or
python_artifact()
.) But I don't want it hardcoded. I want to be able to create a field that can be populated through a number of means and have it be accessible to that function. I was hoping for at least a suggestion on where in the code I should focus on how the various components share information.
w
Like, specifically related to BUILD files? Could a macro help? https://www.pantsbuild.org/2.20/docs/writing-plugins/macros You may also be able to use variables/env vars - I keep my build files super minimal, though, so it's not anything I've specifically done before https://www.pantsbuild.org/2.20/docs/using-pants/key-concepts/targets-and-build-files#environment-variables
w
Yea. Specifically to build files.
Reading this over, I don't think they would work, though it would have been a nice shortcut. I'll be honest that I'm working on a plugin that will allow me to use the vcs_version information in both `python_artifact`/`setup_py` and in
docker_image
for tagging. I was just hoping to be able to get pointed into a specific direction to start researching. I've been going through the code for those specific section, but since they weren't built for that behavior, I need to research some more on the internals of Pants.
Thank you, though!
w
w
Yep. That is the one. It's code currently only writes out to a file, but what I would prefer is to have it leveraged in the actual
python_artifact()
or
setup_py()
call, so it doesn't have to mess with the local git workspace.
w
Ahh, gotcha, that I'm definitely less familiar with. Me personally, that feels like something I'd solve with an env var or something
w
That would probably be the easiest way. But I'm sort of a glutton for punishment. 😄 That being said, I'm also a realist. Is it possible to output something like
vcs_version
into a Environment Variable, instead of a file, and access it where I need it?
w
Not off the top of my head, unfortunately. I don't know how to emit pants stuff into env vars - above, I meant I would have a script and pipe the env vars into the environment
MY_VERSION=whatever pants package ::
I think something like that should work, but would have to find some of my old repos
w
Gotcha. Thanks again!
👍 1