pex question, might be dumb. Is there a way to get...
# pex
e
pex question, might be dumb. Is there a way to get pex to run from files that are not written to ~/.pex? The use case is someone who wants some source files in the pex to be pickleable, and the absolute path to ~/.pex isn’t there when unpickling
Seems related to PEX_ALWAYS_CACHE env var, but I’m not setting that, and stuff is still written there.
Can that be disabled completely
f
you can set PEX_FORCE_LOCAL and PEX_ROOT to force the files in the pex to be written to disk
not sure if that helps with your use case though
e
Hm. it might.
e
But if their code has that fundamental property, they should mark the pex as not zip safe. In Pants for a
python_binary
that's
zip_safe=False
. The env vars just allow you to do this ad-hoc post facto.
e
So what is happening is that the code is calling dill.dump_session which tries to dump the _ main _ module symbols but _ main _ ends up being the pex main I think
a
i believe
zip_safe=False
is the correct way to handle that (to confirm)
e
zip safe doesn’t fix this fyi. Not saying its an issue with pex, But the pex entrypoint is not the module called _ main _ because that is the pex bootstrapper. Basically the point is that pex is not compatible with dill.dump_session, which is probably okay.
e
Basically the point is that pex is not compatible with dill.dump_session, which is probably okay.
Makes sense on all counts. The only way to make Pex compatible with this sort of thing would be a new feature where a pex can be marked zip_hostile=True ( 🙂 ) in which case it would have to fully unzip itself (not just user code and wheels like zip_safe=False does) and then re-exec.
💡 1
That's not an unreasonable feature request, since that mode would allow any application that works not PEXed to definitely continue to work as-is. So if you want to file an issue for that - SGTM. Receptance to that sort of contribution would be positive.
❤️ 1
e
Thanks John. I’ll make an issue, and think about working on it 🙂
I do like how useful pex is and would like to contribute to that
e
Excellent. In case you don't get time to work on it, filling out the description with what zip hostile means would be great. Reading the issue as-is cold turkey it would probably be closed with "already implemented - see
pex --help
for
--not-zip-safe
.
e
Yeah sorry I accidentally submitted it before filling in the description 🤦‍♂️ multiple windows and keyboard mashing