3

I created a simple python script file called main.py which requires some dependency libraries. I pip installed freezed them into a requirements.txt (in a virtualenv) and now I want to package them both to make a single executable that just runs the script

what's the right way to generate it?

thanks in advance

akiva
  • 2,677
  • 3
  • 31
  • 40

1 Answers1

0

To generate a out.pex file from your main.py script and requirements.txt file, you can utilize the following command:

pex -r requirements.txt --exe main.py -o out.pex

It's important to note that the resulting pex file will include your code and its dependencies, but it will not include the Python interpreter. Hence, it is necessary to ensure that the target machine has the appropriate Python interpreter installed.

When you generate the out.pex file using pex 2.1.137, the resulting file structure will typically resemble the following:

.bootstrap/
.deps/  <-- Dependencies will be stored in this directory.
__pex__/
__main__.py  <-- This is the actual entry-point that uses a shebang (hash sign) and wraps your main.py script.
__pex_executable__.py  <-- Your main.py script will be located here.
PEX-INFO
Alireza Roshanzamir
  • 1,165
  • 6
  • 17