https://pantsbuild.org/ logo
#general
Title
# general
f

future-oxygen-10553

02/15/2023, 4:43 PM
I have a question about Pex binaries, which may or may not make sense… we’re using Flyte (https://flyte.org/) to deploy ML workflows. Flyte expects to be able to import our code from <some location> in a docker image (I’m not totally sure where this is, but I can figure it out). My understanding is that Pex files are meant to be executables… but is there a way to import from a pex file? If not, what would be the idomatic way to use pants to put my code into a docker image?
e

enough-analyst-54434

02/15/2023, 4:45 PM
You can import from a PEX file if it is on the PYTHONPATH / sys.path and you execute
import __pex__
1st or else prefix all imports served by the PEX with
__pex__.
, i.e.:
from __pex__.colors import green
.
f

future-oxygen-10553

02/15/2023, 4:45 PM
Oh, interesting…
Thanks for the quick answer, again!
e

enough-analyst-54434

02/15/2023, 4:45 PM
That said, that's not what you want.
With these specific Pants optimizations available: https://blog.pantsbuild.org/optimizing-python-docker-deploys-using-pants/
f

future-oxygen-10553

02/15/2023, 4:46 PM
Oh, perfect, even better
I knew this had to be a solved problem 😄
Is PEX the preferred spelling?
e

enough-analyst-54434

02/15/2023, 4:49 PM
Pex the tool creates PEX files. But I despise language in general and won't be offended by details like that.
f

future-oxygen-10553

02/15/2023, 4:49 PM
😂 I’m the pedant on my team, so I appreciate that there is a distinction
e

enough-analyst-54434

02/15/2023, 4:50 PM
I'd go all e. e. cummings and just say pex since that's what you type and what the common extension - if you use one - is. But I'm not sure how that jives with pedantry.
FWIW the original Pex author used
--indices
instead of `--indexes`but folks found that pedantry confusing so it got un-pedanted! You never know,
f

future-oxygen-10553

02/15/2023, 4:53 PM
The best part about pedantry is that it’s annoying to everyone else no matter what I do 😂
😂 1
e

enough-analyst-54434

02/15/2023, 4:53 PM
Hah!
6 Views