Okay, so assuming I'm dumb enough to jump into bui...
# general
a
Okay, so assuming I'm dumb enough to jump into building a plugin to build a lambda layer, with a week's "experience" of pants, how do I go about this? I've gone through the tutorial written by a friendly community member, and I've got a plugin that supports the package rule. I have a fieldset that takes a bunch of dependencies. All I need to do is: ā€¢ Create a temporary directory ā€¢ Copy each dependency to that temporary directory ā€¢ Create a zip of the directory I can see that there's a
dirutil
module that will create me a temp dir under the build root, but the docs are full of terrifying warnings about IO in rules. Is there something I need to be aware of here in order not to enrage the Cache Gods? From a thread in #general
f
Are the dependencies already available as one or more
Digest
s?
a
At the moment I'm just trudging through code becoming increasingly confused. I can create a RequirementsPexRequest from my target, but I'm failing to create a Pex from that digest. Why do you ask?
I'm thinking that if I create a RequirementsPexRequest, then Get a Pex, I should be able to pass that digest to a Process and do the munging.
f
I ask because if the dependencies are already available as a
Digest
, then you can use the Digest-related API (i.e.,
CreateDigest
,
MergeDigests
,
AddPrefix
,
RemovePrefix
,
DigestEntries
,
DigestContents
) to manipulate the file system tree represented by the
Digest
into the form you need.
a
That's my current plan, but f I try to Get(Pex, requirements_pex_request) I get an ast error, which I'm trying to puzzle out. I suspect it's because I'm running 2.15 but reading code from main
f
Because the Pants setup code needs to read the input and output types out of a
Get
When you have a variable with the input in it, you need to use the three-argument form of
Get
Get(OutputType, InputType, my_input)
a
Ah ha. Excellent, so the places in the code I've seen using the 2 arg form are ... doing what?
I know that's a very stupid question
f
you will note that the two-argument form involves a constructor for the input type
and so the Pants setup code knows what the input type is (and can also just let the constructor call create the input instance)
a
Roger, thank you. I'll give it a whirl
Just fixing a PC with my son šŸ˜‚
awesome, I have a pex in my process. Thank you so much for your patience.
f
I know that's a very stupid question
Not a stupid question; no software is ever obvious, let alone the Pants plugin API
šŸ‘ 1
h
Yeah, there are no stupid questions here, only incomplete documentation
šŸ˜‚ 1
a
tbf, the documentation does make the difference between the two and three arg form clear, but I forgot all about that, and then had an inexplicable ast error.
f
Maybe the AST error should be improved to suggest the three-argument form in these cases?
for example, if the engine setup code sees the two-argument form but the second argument is a lower-cased identifier and thus likely not a Type, then the error could suggest the three-argument form.
a
If I get sufficiently bored, I'll open an issue and a PR to make the suggested change. That would definitely have saved me some time.