We’ve been creating a script like this for each en...
# general
We’ve been creating a script like this for each entrypoint but I’m interested in doing it within the BUILD file if possible
This seems to come up alot. Would it be useful to have a mode where a PEX file worked like busybox? I.E. it tried to map the (internal) binary to run from the basename of the PEX file itself? So for swiss-army-knife.pex:
Copy code
swiss-army-knife.pex # Runs the default entrypoint.
do-foo -> swiss-army-knife.pex # Tries to find and run the do-foo entrypoint or console script.
... etc
s/basename of PEX file itself/sys.argv[0]/
- that must be how the busybox trick works.
yeah basically
that would definitely be useful
Today you can impose the entrypoint from the outside, by setting the env var
when you run the pex
So if the caller knows which entry point it wants, and you don't want to muck around with multiple (potentially large) pex files that are identical except for the entrypoint metadata, you can just do that.
Right, that’s what we’re doing now, via scripts
@echoing-manchester-70122 this came up yet again and this time I sketched a solution - but in a pure Pex context. You can do this today with standard Pex. Here I use importlib but you could use pkg_resources if your PEX needs to run under older pythons: https://github.com/pantsbuild/pex/pull/1350#issuecomment-853186954
👍 1
And, finally, this is all buttoned up. See the demo here: https://github.com/pantsbuild/pex/pull/1350#issuecomment-873348631
The key thing is to just add a
requirement to your multi-pex and make the entrypoint be
-c conscript
and that is all.