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

high-yak-85899

06/14/2022, 3:53 PM
I'd like to do a little poking around manually with contents of the application in my docker container. How could I start up an interactive python shell with the same python interpreter environment my pex app is using? I'm able to
exec
into a bash shell of my container, but not sure how to access the pex's interpreter that has all the third party dependencies I need.
1
c

curved-television-6568

06/14/2022, 4:32 PM
If you have just the
.pex
file, then you can invoke it with
PEX_INTERPRETER=1
to get the Python REPL rather than your normal entry point:
Copy code
$ PEX_INTERPRETER=1 ./cowsay.pex
Python 3.8.11 (default, Aug 28 2021, 14:08:29) 
[Clang 12.0.5 (clang-1205.0.22.11)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import cowsay
>>>
https://pex.readthedocs.io/en/latest/api/vars.html#PEX_INTERPRETER For containers, there’s some neat hints at how to optimize that with pex files: https://pex.readthedocs.io/en/latest/recipes.html#pex-app-in-a-container
h

high-yak-85899

06/14/2022, 5:05 PM
Nice! That's exactly what I wanted.
👍 1
3 Views