2

I have a directory with python libraries and resources (for example unix executable scripts that are forked with subprocess module with different arguments) - total 10-12 files .py + executables. One of them is including the rest and is the interface to the command line tool they make as whole (it currently begins with #!/usr/bin/env python and is executed directly).

Is it possible to make them single executable that's compiled on the machine where they are used for easier transportation (I will create a make file that will handle it)?

I found py2exe but that is for Windows executables. Any suggestions are welcome.

ddinchev
  • 33,683
  • 28
  • 88
  • 133
  • It's not executable, but the common way for Linux is to make a single g-zipped tar file. Why deviate from this standard? – silvado Feb 22 '13 at 13:37
  • you could rename the entry-point script to `__main__.py` and pack all the files in a zip file that can be executed directly, [example](http://stackoverflow.com/a/5356563/4279). – jfs Feb 22 '13 at 13:43

1 Answers1

1

There is pyinstaller (for linux, windows and mac) which you can try: http://www.pyinstaller.org

After downloading the current version (2.0), and extracting it, you can compile a group of *.py files in this way, considering you are in the path to your pyinstaller:

>>> python pyinstaller.py [opts] path_to_yourprogram.py

If you want a single file you can use:

>>> python pyinstaller.py --onefile path_to_yourprogram.py

In the "path_to_yourprogram.py" you have to put the path to your python program that is including the other things.

That's it! pyinstaller will compile your *.py files into a single executable (but as you have some additional resources, such as other executables, I think that you will have also to distribute those additional resources along with your main executable generated by pyinstaller).

sissi_luaty
  • 2,839
  • 21
  • 28