8410838ec80c434d762cd34623cf808e8635f56a
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
31 return os
.path
.dirname(minwii
.__file
__)
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')
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()))
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
)
52 if not os
.path
.exists(dest
) :
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
))
62 s
= os
.path
.join(path
, file)
63 d
= os
.path
.join(dest
, relpath
, file)
65 print os
.path
.join(reldest
, relpath
, file)
66 self
.compiled_files
.append(os
.path
.join(reldest
, relpath
, file))
72 #self.script = "src/minwii/runminwii.py"
75 self
.project_name
= "MINWii"
78 self
.project_url
= "about:none"
81 self
.project_version
= "1.0"
83 #License of the program
87 self
.author_name
= "Samuel Benveniste"
88 self
.author_email
= "samuel.benveniste@gmail.com"
89 self
.copyright
= "Copyright 2010 MINES-ParisTech"
92 self
.project_description
= "Musicothérapie Interractive avec la Wiimote"
94 #Icon file (None will use pygame default icon)
95 self
.icon_file
= 'minwii.ico'
99 #Extra/excludes python modules
100 self
.extra_modules
= []
101 self
.exclude_modules
= []
104 self
.exclude_dll
= ['']
106 #Zip file name (None will bundle files in exe instead of zip file)
107 self
.zipfile_name
= 'minwii_lib.zip'
110 self
.dist_dir
='dist'
114 if os
.path
.isdir(self
.dist_dir
): #Erase previous destination dir
115 shutil
.rmtree(self
.dist_dir
)
117 if os
.path
.isdir('build'): #Clean up build dir
118 shutil
.rmtree('build')
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')
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
,
139 'script': "src/minwii/runminwii.py",
140 'icon_resources': [(0, self
.icon_file
)],
141 'copyright': self
.copyright
144 'script' : "src/minwii/logapp.py",
145 'icon_resources': [(0, 'logapp.ico')],
146 'copyright' : self
.copyright
149 #console = ["src/minwii/logapp.py"],
150 options
= {'py2exe': {'optimize': 1,
153 #'excludes': self.exclude_modules,
154 #'packages': self.extra_modules,
155 #'dll_excludes': self.exclude_dll,
156 'skip_archive' : True
159 zipfile
= self
.zipfile_name
,
160 data_files
= self
.data_files
,
161 dist_dir
= self
.dist_dir
164 #if os.path.isdir('build'): #Clean up build dir
165 # shutil.rmtree('build')
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