2a9b4e75d3a52f499665012931afbd2999c6a15a
1 # -*- coding: utf-8 -*-
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
30 class pygame2exe(py2exe
.build_exe
.py2exe
): #This hack make sure that pygame default font is copied: no need to modify code for specifying default font
31 def copy_extensions(self
, extensions
):
32 #Get pygame default font
33 pygamedir
= os
.path
.split(pygame
.base
.__file
__)[0]
34 pygame_default_font
= os
.path
.join(pygamedir
, pygame
.font
.get_default_font())
36 #Add font to list of extension to be copied
37 extensions
.append(Module("pygame.font", pygame_default_font
))
38 py2exe
.build_exe
.py2exe
.copy_extensions(self
, extensions
)
43 self
.script
= "src/minwii/start_win.py"
46 self
.project_name
= "MINWii"
49 self
.project_url
= "about:none"
52 self
.project_version
= "0.0"
54 #License of the program
55 self
.license
= "MyApps License"
58 self
.author_name
= "Me"
59 self
.author_email
= "example@example.com"
60 self
.copyright
= "Copyright (c) 2009 Me."
63 self
.project_description
= "MyApps Description"
65 #Icon file (None will use pygame default icon)
68 #Extra files/dirs copied to game
69 self
.data_files
= [('minwii/fonts',
70 glob
.glob('src/minwii/fonts/*.ttf'))]
72 #Extra/excludes python modules
73 self
.extra_modules
= []
74 self
.exclude_modules
= []
77 self
.exclude_dll
= ['']
79 #Zip file name (None will bundle files in exe instead of zip file)
80 self
.zipfile_name
= None
87 if os
.path
.isdir(self
.dist_dir
): #Erase previous destination dir
88 shutil
.rmtree(self
.dist_dir
)
90 if os
.path
.isdir('build'): #Clean up build dir
91 shutil
.rmtree('build')
94 #Use the default pygame icon, if none given
95 if self
.icon_file
== None:
96 path
= os
.path
.split(pygame
.__file
__)[0]
97 self
.icon_file
= os
.path
.join(path
, 'pygame.ico')
101 cmdclass
= {'py2exe': pygame2exe
},
102 version
= self
.project_version
,
103 description
= self
.project_description
,
104 name
= self
.project_name
,
105 url
= self
.project_url
,
106 author
= self
.author_name
,
107 author_email
= self
.author_email
,
108 license
= self
.license
,
112 # 'script': self.script,
113 # 'icon_resources': [(0, self.icon_file)],
114 # 'copyright': self.copyright
116 console
= [self
.script
],
117 options
= {'py2exe': {#'optimize': 2,
120 'excludes': self
.exclude_modules
,
121 'packages': self
.extra_modules
,
122 'dll_excludes': self
.exclude_dll
}
124 zipfile
= self
.zipfile_name
,
125 data_files
= self
.data_files
,
126 dist_dir
= self
.dist_dir
129 #if os.path.isdir('build'): #Clean up build dir
130 # shutil.rmtree('build')
132 if __name__
== '__main__':
133 if operator
.lt(len(sys
.argv
), 2):
134 sys
.argv
.append('py2exe')
135 BuildExe().run() #Run generation
136 #raw_input("Press any key to continue") #Pause to let user see that things ends