Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to distribute "statically compiled " Python application with dependencies

I have an application that is based on Python. I want to distribute this application to users on different OS'es (primarily Linux, but various distributions).

What is the recommended way of doing this? I do not want users to have to install Python. I would like to distribute Python with the application (which is free software). Kinda like a statically compiled program.

So that installation of the entire application is just unzipping some files in a folder, and then both Python (and modules used) and the application is all contained in this folder (including subfolders).

How do other people distribute their Python programs?

It is a requirement that the application does not break if the user does install Python on their own or upgrades an existing python. This is why I need to distribute a copy of Python along with the application.

like image 809
ervingsb Avatar asked Mar 26 '12 14:03

ervingsb


4 Answers

What is the recommended way of doing this? I do not want users to have to install Python.

Typically, Python programs are 'packaged' with disutils and installed for use with an existing Python interpreter.

see: Distributing Python Modules and Installing Python Modules

It is not common to bundle the whole interpreter inside your software distribution (though certainly possible).

like image 129
Corey Goldberg Avatar answered Oct 25 '22 09:10

Corey Goldberg


For Windows: py2exe is my preferred solution; you can build an all-in-one .exe, including resources.

For Linux, either:

  • Build an rpm and set Python as dependency, or
  • Build a c executable that integrates python (dll or libpython.so).
like image 35
Gabor Avatar answered Oct 25 '22 08:10

Gabor


See http://www.pyinstaller.org/

like image 42
user1292828 Avatar answered Oct 25 '22 10:10

user1292828


Or, see cx_freeze

From their website:

About cx_Freeze

cx_Freeze is a set of scripts and modules for freezing Python scripts into executables, in much the same way that py2exe and py2app do. Unlike these two tools, cx_Freeze is cross platform and should work on any platform that Python itself works on. It supports Python 2.3 or higher (including Python 3), since it makes use of the zip import facility which was introduced in 2.3.

like image 28
Jay Atkinson Avatar answered Oct 25 '22 08:10

Jay Atkinson