Ajout du thème pgu spécifique à minwii dans l'installateur.
[minwii.git] / setup_win_exe.py
1 # -*- coding: iso-8859-1 -*-
2 # This will create a dist directory containing the executable file, all the data
3 # directories. All Libraries will be bundled in executable file.
4 #
5 # Run the build process by entering 'pygame2exe.py' or
6 # 'python pygame2exe.py' in a console prompt.
7 #
8 # To build exe, python, pygame, and py2exe have to be installed. After
9 # building exe none of this libraries are needed.
10
11 try:
12 from distutils.core import setup
13 import py2exe, pygame
14 from modulefinder import Module
15 import glob, fnmatch
16 import sys, os, shutil
17 import operator
18 except ImportError, message:
19 raise SystemExit, "Unable to load module. %s" % message
20
21
22 origIsSystemDLL = py2exe.build_exe.isSystemDLL
23 def isSystemDLL(pathname):
24 if os.path.basename(pathname).lower() in ["sdl_ttf.dll"]:
25 return 0
26 return origIsSystemDLL(pathname)
27 py2exe.build_exe.isSystemDLL = isSystemDLL
28
29 def findMinwiiDir() :
30 import minwii
31 return os.path.dirname(minwii.__file__)
32
33 class MinWii2exe(py2exe.build_exe.py2exe) :
34 def copy_extensions(self, extensions) :
35 py2exe.build_exe.py2exe.copy_extensions(self, extensions)
36 minwiiDir = findMinwiiDir()
37 self.copyDataFiles(os.path.join(minwiiDir, 'fonts'), 'minwii/fonts')
38 self.copyDataFiles(os.path.join(minwiiDir, 'soundfonts'), 'minwii/soundfonts')
39 self.copyDataFiles(os.path.join(minwiiDir, 'widgets', 'data'), 'minwii/widgets/data')
40
41 pygamedir = os.path.dirname(pygame.base.__file__)
42 pygame_default_font = os.path.join(pygamedir, pygame.font.get_default_font())
43 dest = os.path.join(self.collect_dir, 'pygame', pygame.font.get_default_font())
44 self.copy_file(pygame_default_font, dest)
45 self.compiled_files.append(os.path.join('pygame', pygame.font.get_default_font()))
46
47 def copyDataFiles(self, src, dest) :
48 src = src.replace('/', os.path.sep)
49 reldest = dest.replace('/', os.path.sep)
50 dest = os.path.join(self.collect_dir, reldest)
51
52 if not os.path.exists(dest) :
53 self.mkpath(dest)
54
55 for path, dirs, files in os.walk(src) :
56 if '.svn' in path : continue
57 relpath = path[len(src)+1:]
58 if not os.path.exists(os.path.join(dest, relpath)) :
59 self.mkpath(os.path.join(dest, relpath))
60
61 for file in files :
62 s = os.path.join(path, file)
63 d = os.path.join(dest, relpath, file)
64 self.copy_file(s, d)
65 print os.path.join(reldest, relpath, file)
66 self.compiled_files.append(os.path.join(reldest, relpath, file))
67
68
69 class BuildExe:
70 def __init__(self):
71 #Name of starting .py
72 #self.script = "src/minwii/runminwii.py"
73
74 #Name of program
75 self.project_name = "MINWii"
76
77 #Project url
78 self.project_url = "about:none"
79
80 #Version of program
81 self.project_version = "1.0"
82
83 #License of the program
84 self.license = "GPL"
85
86 #Auhor of program
87 self.author_name = "Samuel Benveniste"
88 self.author_email = "samuel.benveniste@gmail.com"
89 self.copyright = "Copyright 2010 MINES-ParisTech"
90
91 #Description
92 self.project_description = "Musicothérapie Interractive avec la Wiimote"
93
94 #Icon file (None will use pygame default icon)
95 self.icon_file = 'minwii.ico'
96
97 self.data_files = []
98
99 #Extra/excludes python modules
100 self.extra_modules = []
101 self.exclude_modules = []
102
103 #DLL Excludes
104 self.exclude_dll = ['']
105
106 #Zip file name (None will bundle files in exe instead of zip file)
107 self.zipfile_name = 'minwii_lib.zip'
108
109 #Dist directory
110 self.dist_dir ='dist'
111
112
113 def run(self):
114 if os.path.isdir(self.dist_dir): #Erase previous destination dir
115 shutil.rmtree(self.dist_dir)
116
117 if os.path.isdir('build'): #Clean up build dir
118 shutil.rmtree('build')
119
120
121 #Use the default pygame icon, if none given
122 if self.icon_file == None:
123 path = os.path.split(pygame.__file__)[0]
124 self.icon_file = os.path.join(path, 'pygame.ico')
125
126
127 setup(
128 cmdclass = {'py2exe': MinWii2exe},
129 version = self.project_version,
130 description = self.project_description,
131 name = self.project_name,
132 url = self.project_url,
133 author = self.author_name,
134 author_email = self.author_email,
135 license = self.license,
136
137 # targets to build
138 windows = [{
139 'script': "src/minwii/runminwii.py",
140 'icon_resources': [(0, self.icon_file)],
141 'copyright': self.copyright
142 },
143 {
144 'script' : "src/minwii/logapp.py",
145 'icon_resources': [(0, 'logapp.ico')],
146 'copyright' : self.copyright
147 }
148 ],
149 #console = ["src/minwii/logapp.py"],
150 options = {'py2exe': {'optimize': 1,
151 'bundle_files': 3,
152 #'compressed': True,
153 #'excludes': self.exclude_modules,
154 #'packages': self.extra_modules,
155 #'dll_excludes': self.exclude_dll,
156 'skip_archive' : True
157 }
158 },
159 zipfile = self.zipfile_name,
160 data_files = self.data_files,
161 dist_dir = self.dist_dir
162 )
163
164 #if os.path.isdir('build'): #Clean up build dir
165 # shutil.rmtree('build')
166
167 if __name__ == '__main__':
168 if operator.lt(len(sys.argv), 2):
169 sys.argv.append('py2exe')
170 BuildExe().run() #Run generation
171 #raw_input("Press any key to continue") #Pause to let user see that things ends