Python PEX files (https://pex.readthedocs.io/en/latest/) allow one to bundle an application with all its dependencies into a single executable.
It is also possible to bundle up the dependencies into a python interpreter.
I would like, however, to have a "library", something that I can import the libraries from, but without it being a fat interpreter per se. It is possible to just unzip the PEX file, take the wheels out of it, and pip install them, but that relies on the internal structure of a PEX file never changing, and on all the dependencies always being wheels. The main usecase I have in mind is installing dependencies on the spark workers; so if you think deploying a fat python interpreter is a good idea, also let me know.
Is it possible to idiomatically import from an existing PEX file? I don't want to have a completely different process for packaging an executable vs. packaging the dependencies without an executable.
Or is there some clean alternative to PEX that is easy to create with Pants/Gradle? I could script zipping a virtualenv/conda env, but it's not out-of-the-box, and there are some issues with that solution as well.