I think I've asked this before, but can I package ...
# general
a
I think I've asked this before, but can I package a pex that just contains the source, without .deps, .bootstrap, or PEX-INFO? Use case is to build a 'working-directory' for Ray on AWS glue.
1
c
withput PEX-INFO? do you need any of the pex tools? If not, why not just zip them up using an
archive
target?
👍 1
a
Thanks for the reminder 🙂
😅 1
Can I add dependencies of a file through archive, though?
c
I’ve not used archive much, but I think it will pull in any sources/files you have as dependencies to it..
a
Essentially, I want an entrypoint, with its deps, in a zip file, under a single top-level directory. I'll give it a whirl
c
yea, try it out.
if it comes out short, perhaps it’s a missing feature/toggle there…?
a
Hmmm... archive only accepts fIle or resource addresses, it ignores anything else.
Ah well, I'll come back to this later
c
there is this target that I think could turn your python sources into resources: https://www.pantsbuild.org/docs/reference-experimental_wrap_as_resources 😉
a
Noice. I don't deserve you, Andreas.
❤️ 1
b
The new (2.17)
python_aws_lambda_function
behaviour gives a zip with those properties, if you pass
include_requirements=False
, I think.
Although it does include an extra synthetic .py file for the lambda handler itself.
a
At the root?
b
Yeah
a
I'm minded to take a look at that and hack it to do what I need, tbh. I really need two artifacts, one script file, and one zipfile with all the transitive source deps.
And, ideally, a list of the library deps in a json output somewhere, so I can synthesise a pip install argument for the ray job.
So custom target sounds about right.
f
Did you ever figure out how to do this? I am looking for pretty much the same. I’d like a zip with all 3rd party dependencies (including locally referenced ones). We use Poetry at the moment for dependency management. The python_aws_lambda_layer target will create a zip of dependencies, however, any locally referenced ones are not added there (they are added to the python_aws_lambda_function target zip). Any help would be greatly appreciated! Thanks!
a
Yes, specifically for my use case, I have a pants plugin I wrote and can gladly share.
f
That would be great!
f
Thank you! Building python stuff for glue is sort of a pain. Haha.