py2exe requires the creation of setup.py and we just need to import py2exe package and setup script from disutils package like so:
setup.py
-------------------------------------------------------------
from distutils.core import setup
import py2exe
setup(console=['testing.py'])
-------------------------------------------------------------import py2exe
setup(console=['testing.py'])
the next step is to run the setup script on the command prompt like this:
c:\testing > python setup.py py2exe
We will see lots of output printed on the console and at the end two directories will be created -- "build" and "dist" folder, we can delete build directory while dist directory contains the package and windows executables. As I have mentioned a while ago py2exe is not an installer builder if we need one we can use Inno Setup to build one.
Here's my setup script
-------------------------------------------------------------
from distutils.core import setup
import py2exe, os
class build_DIRIncludes(py2exe):
def run(self):
# First, let py2exe do it's work.
py2exe.run(self)
print "--- moving conf ---"
print os.popen('move conf').read()
print "--- moving inputs ---"
print os.popen('move inputs').read()
print "--- moving output ---"
print os.popen('move output').read()
print "done"
setup(
options = {"py2exe": {"optimize": 2,
"packages": ["PyQt4","sip"],
"dist_dir": "my_application",
}
},
windows=['my_application.py'],
cmdclass = {"py2exe": build_DIRIncludes},
)
-------------------------------------------------------------
0 comments:
Post a Comment