Saturday, January 10, 2015

We were investigating frameworks that can help us create stand alone apps using Python back end. Our exploration led us to some unique solutions, that might as well be helpful for people looking to create small apps out of python. What's best that they work even if python is not installed in the target.
We have seen how the Arduino packages the Java interpreter and VM into its UI. We did not want to make the same thing using python. As python programmers have already built us frameworks that can help stand-alone deployment.

We started with two themes - Command line apps and Windowed Apps.
For the command line app the user interface is the command line itself. Possibly the app would need parameters apart from that most of the interaction is prompt driven. This was one of the category of apps that we already had.
Another category was the TCL/TK based apps that have a basic gui designed. This was another category of apps that we wanted to make standalone.
Apparently in Linux the things are a bit easier as you can make the file executable directly but such is not the case in windows.

We have designed 2 examples to help understand the various packages that can help us with this.

Here is a list of the packages that we tested:
  1. Py2Exe
  2. cx-Freeze
  3. PyInstaller
We created two sample programs for this.

Command line Program:
GUI Program:


In order to use these packages here are the installations needed:
  1. Open Command prompt using cmd command in Start Menu
  2. Enter Command SET PATH=C:\Python27;C:\Python27\Scripts;%PATH% to make sure that the Scripts directory is in PATH environment variable This ensures that the Path is configured properly and have access to python package manager.
  3. Now for pip installations use the following Commands:
    pip install cx_freeze PyInstaller virtualenv
    pip install wget - In case one needs a download manager
    pip install --upgrade cx_freeze PyInstaller virtualenv - For upgradation
  4. Download the Py2exe Installations:
  5. Download the PyWin32 Installation:
With these we are ready to for creation of the executable Apps.

We had already prepared python based execution programs tagged as run-*.

Now each package needs specific command to run.

cx-Freeze Procedure

This package system automatically assembles the Distribution package such that all the dependencies are take care off. The space taken by this package is the least. And it generate directly only one directory in the fastest process.
The command used is:
python c:\Python27\Scripts\cxfreeze program.py -O -c --target-dir dist-cx
In order to make this process faster we have a python file run-cxFreeze.py. The command would create the dist-cx directory where the program executable would be created.

PyInstaller Procedure

This package system builds the Dependencies and then build the Distribution with python + support packages. One of the best advantage is that cross dependencies are handled very well.
The command used is:
pyinstaller program.py
We have a runner program in python run-pyinstaller.py. There are also .spec file that would be generated on the basis of default configuration. Further advanced options can be configured by writing the .spec file with custom options. Here is the Documentation Link: http://pythonhosted.org/PyInstaller/

Py2exe Procedure

This package is the oldest of the implemntations. It works by building and then preparing the distribution. In order to make this package work we would need a specific setup.py as the py2exe needes the Python distribution engine to run.
Example setup.py:
from distutils.core import setup
import py2exe
setup(console=['program.py'])
The command used is:
python setup.py py2exe
We have both the setup.py and runner program run-py2exe.py.

Conclusion

We have tested all the three, we found the cx-Freeze to be best unless we would need to many external modules then PyInstaller is better to use.


We have included all this info and created 2 Github Repositories:

Welcome to Boseji's Blog

Popular Post

Blogger templates

Welcome

Creation by Electronics Hobbyists from Bharat(India) to encourage & help people. This blog hosts the numerous innovations, discoveries and projects we provide.
Our Research Wing Adhar Labs
Contact Form | Email Address
We Support Open Source Hardware Definition v1.0
Creative Commons License
All works on this blog are licensed under a
Creative Commons Attribution-ShareAlike 3.0 Unported License.
Based on a work at forbharat.wordpress.com and m8051.blogspot.com.

Permissions beyond the scope of this license may be available at http://forbharat.wordpress.com/permissions/.
Thank you for all your support.

© A.D.H.A.R Labs Research 2008-2013 . Powered by Blogger.

Follow by Email

Followers

PCB Unit Converter

mils
mm

- Copyright © Electronics for Bharat -Robotic Notes- Powered by Blogger - Designed by Johanes Djogan -