Friday, August 3, 2012

quick easy tutorial to use cx_freeze

first we install cx_freeze
then we make setup.py file
we write this code in it :


-----------------------------
#import cx_freeze module
from cx_Freeze import setup,Executable
"""include is a list with the modules you are using in your program (built in modules and modules made by you)
if you use anydbm you should put a database alternative like dbhash or any database module you have"""
includes = ["imp","sys","pickle","somemodule","dbhash","dumbdbm","bsddb","PyQt4.QtCore","PyQt4.QtGui","anydbm","sip","hashlib","anothermodule","itertools","PyQt4","string","time"]
"""script is the main script
base Win32GUI is for windows"""
exe = Executable(script="medcker.py",base="Win32GUI")
#version is the program version
setup(version="3.0",options={"build_exe":{"includes":includes}},executables = [exe])
-------------------------------
then we run if you are on windows by this command
if you have python2.7 :
C:\Python27\python setup.py build
or on linux:
python setup.py build
tips :
1-the main script and any external (not built in) module you want to include should be in the same directory with setup.py
2-the exe file you will find it in your home directory or python directory
3-if you use imp module to import modules you can't include the module you want to import by imp .... you should put the module in the same directory of the exe after making it .

0 comments:

Post a Comment

gotta some thing to say ?

Note: Only a member of this blog may post a comment.