comparison setup.py @ 228:8f4cd1c01d22

Add basic cx_Freeze support in order to freeze to a windows executable.
author Thibaut Girka <thib@sitedethib.com>
date Tue, 20 Dec 2011 21:17:34 +0100
parents 5c5913b889bc
children cbe9dbd80dfb
comparison
equal deleted inserted replaced
227:31460b2ec530 228:8f4cd1c01d22
5 from distutils.extension import Extension 5 from distutils.extension import Extension
6 from distutils.command.build_scripts import build_scripts 6 from distutils.command.build_scripts import build_scripts
7 from distutils.dep_util import newer 7 from distutils.dep_util import newer
8 from distutils import log 8 from distutils import log
9 9
10
11 # Cython is needed 10 # Cython is needed
12 try: 11 try:
13 from Cython.Distutils import build_ext 12 from Cython.Distutils import build_ext
14 except ImportError: 13 except ImportError:
15 print('You don’t seem to have Cython installed. Please get a ' 14 print('You don’t seem to have Cython installed. Please get a '
16 'copy from www.cython.org and install it') 15 'copy from www.cython.org and install it')
17 sys.exit(1) 16 sys.exit(1)
17
18
19 packages = []
20 extension_names = []
21 extensions = []
22
18 23
19 24
20 # The installed script shouldn't call pyximport, strip references to it 25 # The installed script shouldn't call pyximport, strip references to it
21 class BuildScripts(build_scripts): 26 class BuildScripts(build_scripts):
22 def copy_scripts(self): 27 def copy_scripts(self):
32 out.write(line) 37 out.write(line)
33 38
34 build_scripts.copy_scripts(self) 39 build_scripts.copy_scripts(self)
35 40
36 41
37 packages = []
38 extensions = []
39 42
40 for directory, _, files in os.walk('pytouhou'): 43 for directory, _, files in os.walk('pytouhou'):
41 package = directory.replace(os.path.sep, '.') 44 package = directory.replace(os.path.sep, '.')
42 packages.append(package) 45 packages.append(package)
43 for filename in files: 46 for filename in files:
44 if filename.endswith('.pyx'): 47 if filename.endswith('.pyx'):
45 extension_name = '%s.%s' % (package, os.path.splitext(filename)[0]) 48 extension_name = '%s.%s' % (package, os.path.splitext(filename)[0])
49 extension_names.append(extension_name)
46 extensions.append(Extension(extension_name, 50 extensions.append(Extension(extension_name,
47 [os.path.join(directory, filename)])) 51 [os.path.join(directory, filename)]))
48 52
49 53
50 54
55 # TODO: find a less-intrusive, cleaner way to do this...
56 try:
57 from cx_Freeze import setup, Executable
58 except ImportError:
59 extra = {}
60 else:
61 extra = {
62 'options': {'build_exe': {'includes': extension_names}},
63 'executables': [Executable(script='scripts/eosd', base='Win32GUI')]
64 }
65
66
67
51 setup(name='PyTouhou', 68 setup(name='PyTouhou',
69 version="0.1",
52 author='Thibaut Girka', 70 author='Thibaut Girka',
53 author_email='thib@sitedethib.com', 71 author_email='thib@sitedethib.com',
54 url='http://hg.sitedethib.com/touhou/', 72 url='http://hg.sitedethib.com/touhou/',
55 license='GPLv3', 73 license='GPLv3',
56 packages=packages, 74 packages=packages,
57 ext_modules=extensions, 75 ext_modules=extensions,
58 scripts=['scripts/eosd'], 76 scripts=['scripts/eosd'],
59 cmdclass={'build_ext': build_ext, 77 cmdclass={'build_ext': build_ext,
60 'build_scripts': BuildScripts} 78 'build_scripts': BuildScripts},
79 **extra
61 ) 80 )
62 81