forked from renpy/renpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_exe.py
111 lines (82 loc) · 3.3 KB
/
build_exe.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
#!/usr/bin/env python
import modulefinder
import shutil
from distutils.core import setup
import py2exe #@UnresolvedImport @UnusedImport
import sys
import zipfile
import traceback
import os
# The pythonpath on my system.
sys.path.insert(0, 'c:\\msys\\1.0\\newbuild\\install\\bin')
sys.path.insert(0, 'c:\\msys\\1.0\\newbuild\\install\\python')
def move_from_dist(fn):
"""
Moves the file `fn` from the dist directory to the main
directory. (This means we don't need symlinks on windows.)
"""
if os.path.isdir(fn):
shutil.rmtree(fn)
elif os.path.exists(fn):
os.unlink(fn)
os.rename("dist/" + fn, fn)
import renpy
renpy.setup_modulefinder(modulefinder) #@UndefinedVariable
def main():
sys.argv[1:] = [ 'py2exe', '-a', '--dll-excludes', 'w9xpopen.exe', ]
setup(name="Ren'Py",
windows=[ dict(script="renpy.py",
dest_base="renpy",
icon_resources=[ (1, "newicon.ico") ],
),
],
console=[ dict(script="renpy.py", dest_base="console") ],
zipfile='lib/windows-x86/renpy.code',
options={ 'py2exe' : { 'excludes' : [ 'doctest',
'pygame.macosx',
'pygame.surfarray',
'pygame.mixer',
'pygame.mixer_music',
'_ssl',
'_hashlib',
'win32con',
'win32api',
'Numeric',
'os2emxpath',
'macpath',
'multiprocessing',
'_multiprocessing',
],
'optimize' : 2,
} },
)
zfold = zipfile.ZipFile("dist/lib/windows-x86/renpy.code")
zfnew = zipfile.ZipFile("dist/lib/windows-x86/renpy.code.new", "w", zipfile.ZIP_STORED)
seen = { }
for fn in zfold.namelist():
if fn.startswith("renpy/"):
# Keep around .pyo files that load pyd files.
pydfn = fn.replace("/", ".").replace(".pyo", ".pyd")
if not os.path.exists("dist/lib/windows-x86/" + pydfn):
continue
if fn in seen:
continue
if fn == "SDL_mixer.dll":
continue
seen[fn] = True
zfnew.writestr(fn, zfold.read(fn))
zfold.close()
zfnew.close()
os.unlink("dist/lib/windows-x86/renpy.code")
os.rename("dist/lib/windows-x86/renpy.code.new", "dist/lib/windows-x86/renpy.code")
# Take these files from the old python.
shutil.copy("c:/Python26/Microsoft.VC90.CRT.manifest", "Microsoft.VC90.CRT.manifest")
shutil.copy("c:/Python26/msvcr90.dll", "msvcr90.dll")
move_from_dist("lib/windows-x86")
move_from_dist("console.exe")
move_from_dist("python27.dll")
move_from_dist("renpy.exe")
try:
main()
except:
traceback.print_exc()