From 9da225414be62c0e7dd11efb03e769207d8fe230 Mon Sep 17 00:00:00 2001 From: Drew Fisher Date: Sun, 2 Aug 2009 19:38:31 -0700 Subject: [PATCH] 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. --- setup.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 setup.py 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) + ] +) + -- 2.39.2