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.

2
  • It's not executable, but the common way for Linux is to make a single g-zipped tar file. Why deviate from this standard? Commented Feb 22, 2013 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. Commented Feb 22, 2013 at 13:43

1 Answer 1

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).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.