Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Distribute a Python program with a minimal environment

I want to distribute a Python application to windows users who don't have Python or the correct Python version.

I have tried py2exe conversion but my Python program is really complex and involve code import on the fly by xmlrpc process so it is not suitable for py2exe.

The complete Python folder takes around 80MB but this includes docs and a lot of non-essential things.

Do you know if there exists a small package of a minimal Python interpreter I can include with my program ? Include a folder of 80MB is a bit big ;)

like image 471
X-Blaster Avatar asked Nov 23 '09 11:11

X-Blaster


People also ask

How do you distribute a Python program?

The most convenient way to deliver a Python application to a user is to provide them with an executable—either a single file or a directory with an easily identified executable somewhere in it.

How do I make a Python script distributable?

You can use a tool like PyInstaller to convert your script (. py file) into an executable (.exe on windows). The way that works is PyInstaller copies both the python interpretor and your script into a single file so that you can distribuite your program easily.

Should I package my Python project?

Yes, its a good idea to package projects especially if you want to use them in multiple environments. pip can install a local wheel or archive, a local directory where you've checked out the code, a private web server, one of several version control systems like git.


2 Answers

PyInstaller is a py2exe "competitor" that has many extras (such as being cross-platform, supporting popular third party packages "out of the box", and explicitly supporting advanced importing options) -- it might meet your needs. Just be sure to install the SVN trunk -- the existing (1.3) release is way, WAY obsolete (PyInstaller is under active development again since quite a while, but I can't convince the current maintainers to stop and do a RELEASE already -- they're kind of perfectionists and keep piling more and more great goodies, optimizations, enhancements, etc, into the SVN trunk instead;-).

like image 83
Alex Martelli Avatar answered Oct 26 '22 02:10

Alex Martelli


Have a look at Portable Python. This will install a Python programming environment in a local folder. I am sure that you could strip many unwanted things off.

I recommend however that you give py2exe another chance.

like image 42
kgiannakakis Avatar answered Oct 26 '22 02:10

kgiannakakis