Python for experts - Shipping part 1
The last one of my previous series of posts on Python addresses the issue of shipping Python applications.
Simply put, if I ask people to help my research by using an application that I developed, I do not want to force them to:
- read large manuals
- unzip and fiddle with my 'distributed zipped folder' with executables, DLLs, and other helper files
- install/uninstall stuff on their machine
- waste their time
On Windows, I could only find two tools that claim to accomplish that:
py2exe
PyInstaller
Both have options to deliver either a distribution folder or a standalone file executable. I was only interested on the latter option.
py2exe seems to have problems with applications using Tkinter for the GUI. For my server module, which does not have a GUI, the setup file below did the job.
# setup.py
from distutils.core import setup
import py2exe
setup(data_files=[("abbreviations.txt")],
name = "Jiim Server",
description = "Cross-Linguist Server Prototype.",
version = "1.1",
author='Jorge De Castro',
author_email='jorge at bcs dot org dot uk',
zipfile=None,
console= [{"script": "server.py"}]
)
This yielded a server.exe standalone file with 4.5Mb.
PyInstaller hit the spot. It is simple to use (simpler than py2exe) and their documentation is very good. Furthermore, after I installed UPX as instructed on their homepage, the executable created was compressed to less than half(!) the size (1.85Mb) of the one created with py2exe. The command line options I used are shown below:
> python Makespec.py --onefile --name=server C:\Workplace\python\jiim\server.py
> python Build.py server\server.spec
It seems possible to have py2exe do the same (or most) things PyInstaller does, but the latter is much nicer and easier to use. Plus, it just works as expected.
Be prepared to struggle with py2exe's (lack of) documentation if you want slightly more complex setups.
No comments:
Post a Comment