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