If I'm creating a plugin that takes in the output ...
# plugins
w
If I'm creating a plugin that takes in the output of a python_distribution (i.e. wheel), are there examples of where that's currently done in any existing plugins? I can see how I can grab source files just fine - but I'm less sure about outputs of other targets. I've pulled in and taken a dependency on the python_dist target, but I can't figure out which API will let me grab that wheel
That is, you do something like
await Get(BuiltPackage, PackageFieldSet, PackageFieldSet.create(tgt))
to get the built wheel etc in a digest
(as one way to get the Field set)
w
Hmm, okay, so I guess taking one step back, how can I get my target in a rule (and only my target)? I tried some of the examples in the documentation, but that spews a whole ton of warnings and errors. I've got, what I think is a working example, however my rule seems to run on each package that's created, rather than JUST my target e.g. My rule runs for my target, for my target's dependency, and then on each source file - which is definitely not what I want
Copy code
async def package_pyoxidizer_binary(field_set: PyOxidizerFieldSet) -> BuiltPackage:
    targets = await Get(Targets, DependenciesRequest(field_set.dependencies))

13:40:09.55 [INFO] Received these targets inside pyox targets: ['helloworld:helloworld-dist']
13:40:09.56 [INFO] Received these targets inside pyox targets: ['helloworld/__init__.py:libhelloworld', 'helloworld/main.py:libhelloworld']
13:40:11.38 [INFO] Received these targets inside pyox targets: []
I get that those dependencies will run their own targets, but not sure why my rule is run with them
c
Ah, what does your Target for
py_oxidizer
(or is it
pyox
?) look like (both the Python class, and in the BUILD file) ?
Perhaps you can push to a wip branch in your fork, and I can take a look… ?
nvm if it doesn’t work or is cleaned up etc.. 😉
w
I've got a staging area right now - having something that "runs" but the file ends up in /private/tmp somewhere, and isn't copied to dist. But, I think it's still running my rule multiple times. Just pushing it now
./pants package helloworld:helloworld-bin
You want to have a field unique to your target to put in required fields for your fields set, to limit down what targets you get
Ah, which means, put your
PyOxidizerDepedenciesField
in there..
w
Ahhhh damn, thanks - I think there is even a note in the documentation that warns/informs about this - and I was thinking to make sure to be careful about it
c
no worries, there’s a lot to take in
w
And there we go, no more multiple runs 🤦 Thanks!
🎉 2
c
Looks great, good start! 😄
👍 1
what’s the story behind
oxy_clean
though? (/me curious)
w
Lol, there is none - I didn't want to think of a name for the target, as doing that would slow down me starting the plugin work - so I just put the first absurd thing (so I know to fix it later) I could come up with that had oxy in it. OxiClean is a commercial I've seen a lot over the years, and I guess it's just there in my head
😂 1
c
LOL- ok, makes sense then 🤣
w
Does Pants auto-delete the temporary working directories it uses?
/private/var/folders/18/q1r7phps28nc9rx5j_0t3jmm0000gp/T/process-executiongGTfnJ/./build/x86_64-apple-darwin/debug/exe/helloworld-bin
I'm getting a bin, but can't actually get it in my dist folder, and then that folder above auto-deletes itself before I can even stat the binary
Aha, never mind - I needed to put those deps into another digest before I could use them in the PexProcess. This is really mind blowing stuff when you just dive into the weeds. 🙂 On the plus side, the plugin works with hello world :)
❤️ 1
c
Really cool 😎