-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_py2exe.py
126 lines (113 loc) · 3.42 KB
/
make_py2exe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
from distutils.core import setup
import py2exe
import os
import shutil
import re
import sys
import contrib
import config
import glob
from util.i18n import find_languages
version = sys.argv[-1]
if re.findall("^([0-9]+\.)*[0-9]+(b[0-9]+)?$", version):
del sys.argv[-1]
else:
version = "None"
if "py2exe" not in sys.argv:
sys.argv.append('py2exe')
manifest = """
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<assemblyIdentity
version="0.64.1.0"
processorArchitecture="x86"
name="Controls"
type="win32"
/>
<description>BPBible - Flexible Bible Study</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.VC90.CRT"
version="9.0.21022.8"
processorArchitecture="x86"
publicKeyToken="1fc8b3b9a1e18e3b"
/>
</dependentAssembly>
</dependency>
</assembly>
"""
#os.system("del /s *.pyc")
#os.system("del /s *.xcfg")
#os.system("del /s *.*~")
py2exe_options = {
"optimize": 1,
"dll_excludes": "msvcp90.dll"
}
zipfile = "library.zip"
if "compressed" in sys.argv:
py2exe_options.update({
"compressed": 1,
"bundle_files": 1,
})
sys.argv.remove("compressed")
zipfile = None
languages = find_languages(is_release=True)
data_files = []
# You will need to include this directory when building with Python 2.6.
# The manifest says that the directory will be there, since it depends on MSVC 9.
# You can get the directory from VC++ 2008 Express (read redist.txt).
if os.path.isdir('Microsoft.VC90.CRT'):
vc_files = glob.glob('Microsoft.VC90.CRT\\*.*')
data_files += [
("Microsoft.VC90.CRT", vc_files),
]
if(setup(
options = {"py2exe": py2exe_options},
data_files = data_files,
windows = [
{
"script":('bpbible.py'),
"icon_resources":[(1, "graphics/bpbible.ico")],
"other_resources": [(24,1,manifest)],
"description": "BPBible - Flexible Bible Study",
"version": version,
"name": "BPBible",
}
],
zipfile=zipfile,
)):
subdirs = r"xrc graphics css js xulrunner resources locales locales\locales.d".split()
subdirs += ["locales\%s\LC_MESSAGES\\" % l for l in languages]
for subdir in subdirs:
os.system(r"if not exist dist\%s mkdir dist\%s" % (subdir, subdir))
os.system("copy xrc\\*.xrc dist\\xrc\\")
for item in "png gif".split():
os.system("copy graphics\\*.%s dist\\graphics\\" % item)
os.system("copy LICENSE.txt dist\\")
os.system(r"copy locales\locales.d\*.conf dist\locales\locales.d")
complete_copy_dirs = "resources css js xulrunner".split()
for subdir in complete_copy_dirs:
os.system(r"xcopy /e /Y %s dist\%s" % (subdir, subdir))
for root, dirs, files in os.walk('dist\\%s' % subdir):
if '.svn' in dirs:
shutil.rmtree(os.path.join(root, '.svn'))
dirs.remove('.svn')
for item in languages:
os.system("copy locales\%s\LC_MESSAGES\messages.mo "
"dist\locales\%s\LC_MESSAGES\messages.mo" % (item, item))
os.system("copy locales\%s\locale.conf dist\locales\%s\locale.conf" % (item, item))