Increase thumbnail size
[joel/kofoto.git] / build-windows-py2exe-installer.py
1 #! /usr/bin/env python
2
3 import glob
4 import os
5 import py2exe
6 import setup
7 import shutil
8 import sys
9 import _winreg
10 from os.path import join, isdir
11
12 def zap(glob_pattern):
13     for entry in glob.glob(glob_pattern):
14         if os.path.isdir(entry):
15             shutil.rmtree(entry)
16         else:
17             os.remove(entry)
18
19 options = {
20     "py2exe": {
21         "includes": "pango,atk,gobject",
22         "packages": ["encodings"],
23         },
24     }
25
26 shutil.copy("src/cmdline/kofoto", "kofoto.py")
27 shutil.copy("src/gkofoto/start-installed.py", "gkofoto.py")
28 shutil.copy("packaging/windows/plugin-modules-to-ship.py", "plugin-modules-to-ship.py")
29 console = ["kofoto.py", "plugin-modules-to-ship.py"]
30 windows = ["gkofoto.py"]
31 sys.argv = [sys.argv[0], "py2exe"]
32
33 setup.run(options=options, console=console, windows=windows)
34
35 zap("kofoto.py")
36 zap("gkofoto.py")
37 zap("plugin-modules-to-ship.py")
38 zap("dist/plugin-modules-to-ship.exe")
39 zap("dist/tcl")
40 zap("dist/tcl*.dll")
41 zap("dist/tk*.dll")
42
43 # py2exe doesn't find these libraries needed by libpixbufloader-*.dll plugins:
44 for libname in ["libpng12.dll", "jpeg62.dll"]:
45     shutil.copy(join(os.environ["GTK_BASEPATH"], "bin", libname), "dist")
46
47 k = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "Software\\GTK\\2.0")
48 gtkdir = _winreg.QueryValueEx(k, "Path")[0]
49 for dir in ["bin", "etc", "lib", "share"]:
50     for dirpath, dirnames, filenames in os.walk(join(gtkdir, dir)):
51         destdir = join("dist", dirpath[len(gtkdir) + 1:])
52         if not isdir(destdir):
53             os.makedirs(destdir)
54         for filename in filenames:
55             print "copying %s --> %s" % (join(dirpath, filename), destdir)
56             shutil.copy(join(dirpath, filename), destdir)
57 zap("dist/share/gtk-*/demo")
58
59 shutil.copy("COPYING.txt", "dist/license.txt")
60 license_file = open("dist/license.txt", "a")
61 for x in ["python", "gtk", "pygtk", "pil", "pysqlite"]:
62     f = open("packaging/%s-license.txt" % x)
63     license_file.write("\n")
64     license_file.write(f.read())
65
66 versionDict = {}
67 execfile("src/packages/kofoto/version.py", versionDict)
68
69 print "creating kofoto.iss"
70 template = \
71     open("packaging/windows/kofoto.iss.template").read() \
72         .replace("%version%", versionDict["version"]) \
73         .replace("%licensefile%", join(os.getcwd(), "dist", "license.txt")) \
74         .replace("%distdir%", join(os.getcwd(), "dist"))
75 issfile = open("kofoto.iss", "w")
76 issfile.write(template)
77
78 print "Finished successfully."
79 print "Press enter."
80 sys.stdin.readline()