86702fc855659f7770f2fc47ce0e7d9f68feaee5
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.
5 # Run the build process by entering 'pygame2exe.py' or
6 # 'python pygame2exe.py' in a console prompt.
8 # To build exe, python, pygame, and py2exe have to be installed. After
9 # building exe none of this libraries are needed.
12 from distutils
.core
import setup
14 from modulefinder
import Module
16 import sys
, os
, shutil
18 except ImportError, message
:
19 raise SystemExit, "Unable to load module. %s" % message
22 origIsSystemDLL
= py2exe
.build_exe
.isSystemDLL
23 def isSystemDLL(pathname
):
24 if os
.path
.basename(pathname
).lower() in ["sdl_ttf.dll"]:
26 return origIsSystemDLL(pathname
)
27 py2exe
.build_exe
.isSystemDLL
= isSystemDLL
29 def findPguThemesDir() :
31 theme_file
= pgu
.gui
.theme
.__file
__
33 dnames
.append(os
.path
.join(os
.path
.dirname(theme_file
),"..","..","data","themes"))
35 #if the package is installed, and the package is installed
36 #in /usr/lib/python2.3/site-packages/pgu/
37 #or c:\python23\lib\site-packages\pgu\
38 #the data is in ... lib/../share/ ...
39 dnames
.append(os
.path
.join(os
.path
.dirname(theme_file
),"..","..","..","..","share","pgu","themes"))
40 dnames
.append(os
.path
.join(os
.path
.dirname(theme_file
),"..","..","..","..","..","share","pgu","themes"))
41 dnames
.append(os
.path
.join(os
.path
.dirname(theme_file
),"..","..","share","pgu","themes"))
43 if os
.path
.isdir(dname
):
45 raise IOError('pgu themes folder not found')
48 class MinWii2exe(py2exe
.build_exe
.py2exe
) :
49 def copy_extensions(self
, extensions
) :
50 py2exe
.build_exe
.py2exe
.copy_extensions(self
, extensions
)
52 self
.copyDataFiles('src/minwii/fonts', 'minwii/fonts')
53 self
.copyDataFiles('src/minwii/soundfonts', 'minwii/soundfonts')
54 self
.copyDataFiles('src/minwii/widgets/data', 'minwii/widgets/data')
55 self
.copyDataFiles(findPguThemesDir(), 'data/themes')
57 pygamedir
= os
.path
.dirname(pygame
.base
.__file
__)
58 pygame_default_font
= os
.path
.join(pygamedir
, pygame
.font
.get_default_font())
59 dest
= os
.path
.join(self
.collect_dir
, 'pygame', pygame
.font
.get_default_font())
60 self
.copy_file(pygame_default_font
, dest
)
61 self
.compiled_files
.append(os
.path
.join('pygame', pygame
.font
.get_default_font()))
63 def copyDataFiles(self
, src
, dest
) :
64 src
= src
.replace('/', os
.path
.sep
)
65 reldest
= dest
.replace('/', os
.path
.sep
)
66 dest
= os
.path
.join(self
.collect_dir
, reldest
)
68 if not os
.path
.exists(dest
) :
71 for path
, dirs
, files
in os
.walk(src
) :
72 if '.svn' in path
: continue
73 relpath
= path
[len(src
)+1:]
74 if not os
.path
.exists(os
.path
.join(dest
, relpath
)) :
75 self
.mkpath(os
.path
.join(dest
, relpath
))
78 s
= os
.path
.join(path
, file)
79 d
= os
.path
.join(dest
, relpath
, file)
81 print os
.path
.join(reldest
, relpath
, file)
82 self
.compiled_files
.append(os
.path
.join(reldest
, relpath
, file))
88 self
.script
= "src/minwii/minwii_fullscreen.py"
91 self
.project_name
= "MINWii"
94 self
.project_url
= "about:none"
97 self
.project_version
= "1.0"
99 #License of the program
103 self
.author_name
= "Samuel Benveniste"
104 self
.author_email
= "samuel.benveniste@gmail.com"
105 self
.copyright
= "Copyright 2010 MINES-ParisTech"
108 self
.project_description
= "Musicothérapie Interractive avec la Wiimote"
110 #Icon file (None will use pygame default icon)
111 self
.icon_file
= 'minwii.ico'
115 #Extra/excludes python modules
116 self
.extra_modules
= []
117 self
.exclude_modules
= []
120 self
.exclude_dll
= ['']
122 #Zip file name (None will bundle files in exe instead of zip file)
123 self
.zipfile_name
= 'minwii_lib.zip'
126 self
.dist_dir
='dist'
130 if os
.path
.isdir(self
.dist_dir
): #Erase previous destination dir
131 shutil
.rmtree(self
.dist_dir
)
133 if os
.path
.isdir('build'): #Clean up build dir
134 shutil
.rmtree('build')
137 #Use the default pygame icon, if none given
138 if self
.icon_file
== None:
139 path
= os
.path
.split(pygame
.__file
__)[0]
140 self
.icon_file
= os
.path
.join(path
, 'pygame.ico')
144 cmdclass
= {'py2exe': MinWii2exe
},
145 version
= self
.project_version
,
146 description
= self
.project_description
,
147 name
= self
.project_name
,
148 url
= self
.project_url
,
149 author
= self
.author_name
,
150 author_email
= self
.author_email
,
151 license
= self
.license
,
155 'script': self
.script
,
156 'icon_resources': [(0, self
.icon_file
)],
157 'copyright': self
.copyright
159 #console = [self.script],
160 options
= {'py2exe': {'optimize': 2,
163 #'excludes': self.exclude_modules,
164 #'packages': self.extra_modules,
165 #'dll_excludes': self.exclude_dll,
166 'skip_archive' : True
169 zipfile
= self
.zipfile_name
,
170 data_files
= self
.data_files
,
171 dist_dir
= self
.dist_dir
174 #if os.path.isdir('build'): #Clean up build dir
175 # shutil.rmtree('build')
177 if __name__
== '__main__':
178 if operator
.lt(len(sys
.argv
), 2):
179 sys
.argv
.append('py2exe')
180 BuildExe().run() #Run generation
181 #raw_input("Press any key to continue") #Pause to let user see that things ends