From: Drew Fisher Date: Mon, 3 Aug 2009 02:38:31 +0000 (-0700) Subject: Add a Python DistUtils py2exe script X-Git-Url: https://git.zarvox.org/shortlog/month?a=commitdiff_plain;h=9da225414be62c0e7dd11efb03e769207d8fe230;p=wp3.git Add a Python DistUtils py2exe script Now you can package up this executable for Windows, so people can run it without having to have the development environment installed. Just run python setup.py py2exe and you get the dist/ folder with the executable and all dependencies. Prerequisites: Have PyQt4, python-ldap, DistUtils, and py2exe installed. --- diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..5f8aefb --- /dev/null +++ b/setup.py @@ -0,0 +1,43 @@ +# This is a DistUtils setup script to be used with py2exe, a DistUtils extension. +# +# To create the redistributable package, run: +# python setup.py py2exe +# +# You may need to change the following line to accurately show the location of +# your PyQt4 plugins folder: +plugins_base = "C:\\Python26\\Lib\\site-packages\\PyQt4\\plugins" + +from py2exe.build_exe import py2exe +from distutils.core import setup +import os + +# We need the sqlite3 SQL driver, implemented as a plugin +sqldrivers_files = [plugins_base + "\\sqldrivers\\qsqlite4.dll"] + +# We need the JPG image format plugin, but we might as well grab them all +imageformats_files = [] +image_base = plugins_base + "\\imageformats\\" +for f in os.listdir(image_base): + p = image_base + f + if os.path.isfile(p): # skip directories + imageformats_files.append(p) + +# Invoke the distutils setup command with appropriate options +setup( + options = { + "py2exe": { + # 1 or 2 (packing libs into the .exe) seem to have massive issues with image format plugin loading + "bundle_files": 3, + # We declare these here, otherwise they don't get pulled in (and are needed at runtime) + "includes": ["sip","PyQt4.QtSql"] + } + }, + console = [{"script": "mainapp.py"}], + zipfile = None, + data_files = [ + ("", ["README","LICENSE"]), + ("sqldrivers", sqldrivers_files), + ("imageformats", imageformats_files) + ] +) +