How can I distribute python programs?

My application is as follows:

 main.py
 windows /
     __init__.py
     mainwindow.py
     ...
 model /
     __init__.py
     orders.py
     ...
 resources /
     image1.png
     logo.jpg
     ...

The program starts with main.py. Is there a good way to create a โ€œfinalโ€ application from it? I am thinking of something like py2exe / py2app, but not copying the python interpreter / modules into an application that has only one executable.

I looked at distutils, but it looks like it is installing the program in the Python directory, which is not common on platforms other than Linux.

For the moment, I'm just copying the entire source folder to the target machine and creating the main.pyw alias in the windows. Some inconveniences:

  • The icon is the default python icon.
  • I need to create an alias manually.
  • There are many additional files in my source directory, such as a source folder.
  • I need to manually rename main.py to main.pyw .
  • It would be nice if only .pyo * files are on the target machine. There is no real reason for this; I just don't like having unnecessary files.

How to create a good automatic distribution?

  • for windows? (This is the only platform I should support at the moment.)
  • for mac?
  • for linux?
+73
python distribution
Oct 13 '09 at 5:48
source share
5 answers

The usual way to distribute Python applications is through distutils . This was done both for distributing libraries like python modules and for python applications, although I don't know how this works on Windows. On Windows, you will have to install Python separately if you use distutils, anyway.

I would recommend you distribute it with disutils for Linux and Py2exe or something similar for Windows. For OS X, I do not know. If this is an end-user application, you will probably need a disk image type, I don't know how to do it. But read this post for more information on its user experience. For an application built for programmers, you're probably fine with installing distutils on OS X.

+29
Oct 13 '09 at 5:54
source share

I highly recommend Pyinstaller , which almost completely supports all major platforms. Like py2exe and py2app, it creates a standard executable file on Windows and a set of applications on OS X, but it is of great importance also does a fantastic job of automatically resolving common dependencies and includes them without additional configuration settings.

Also note that if you are deploying Python 2.6 on Windows, you must apply this patch to the Pyinstaller trunk.

You indicated that you do not need an installer, but Inno Setup is an easy-to-use and quick choice for the Windows platform.

+44
Oct 13 '09 at 6:31
source share

Fredrik Lundh squeeze.py can create a single file that does not contain the Python interpreter, but instead contains bytecode. With the correct arguments, you can include other files, modules, etc. in the result file. I have successfully used it in one project. The resulting program worked on OS X, Linux, and Windows without any problems!

PS . Each machine must have a Python interpreter that is compatible with the bytecode generated by the squeeze.py command. You can create different versions of bytecode for different versions of Python if necessary (just run squeeze.py with the correct version of Python).

+5
Oct 13 '09 at 7:02
source share

Maybe I'm wrong, but IronPython does not have a built-in compiler for windows?

http://www.ironpython.net

[EDIT]

Try Cx_Freeze, which is by far the best .py in .exe (plus a few .dlls) compiler I have ever used.

http://cx-freeze.sourceforge.net/

+2
May 28 '13 at 1:29
source share

If you are distributing on windows, use the installer to install all the necessary files / interpreters no matter what you need. Distribute the setup.exe file. This is the best way for windows. Otherwise, users will complain.

+1
Oct 13 '09 at 6:11
source share



All Articles