annotate setup.py @ 418:63f59be04a54

Replace Pyglet with SDL2 for window creation and events; disables framerate control/display and sound.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 16 Jul 2013 21:07:15 +0200
parents cbe9dbd80dfb
children 3a7b36324611
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
1 # -*- encoding: utf-8 -*-
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
2
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 import os, sys
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
4 from distutils.core import setup
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
5 from distutils.extension import Extension
219
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
6 from distutils.command.build_scripts import build_scripts
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
7 from distutils.dep_util import newer
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
8 from distutils import log
418
63f59be04a54 Replace Pyglet with SDL2 for window creation and events; disables framerate control/display and sound.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 237
diff changeset
9 from subprocess import check_output
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
10
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
11 # Cython is needed
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12 try:
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
13 from Cython.Distutils import build_ext
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14 except ImportError:
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
15 print('You don’t seem to have Cython installed. Please get a '
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16 'copy from www.cython.org and install it')
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
17 sys.exit(1)
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
18
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
19
418
63f59be04a54 Replace Pyglet with SDL2 for window creation and events; disables framerate control/display and sound.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 237
diff changeset
20 COMMAND = 'pkg-config'
63f59be04a54 Replace Pyglet with SDL2 for window creation and events; disables framerate control/display and sound.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 237
diff changeset
21 LIBRARIES = ['sdl2']
63f59be04a54 Replace Pyglet with SDL2 for window creation and events; disables framerate control/display and sound.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 237
diff changeset
22
228
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
23 packages = []
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
24 extension_names = []
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
25 extensions = []
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
26
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
27
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
28
219
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
29 # The installed script shouldn't call pyximport, strip references to it
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
30 class BuildScripts(build_scripts):
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
31 def copy_scripts(self):
226
5c5913b889bc Fix setup.py...
Thibaut Girka <thib@sitedethib.com>
parents: 219
diff changeset
32 self.mkpath('scripts')
219
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
33 for script in (os.path.basename(script) for script in self.scripts):
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
34 outfile = os.path.join('scripts', script)
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
35 if not self.force and not newer(script, outfile):
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
36 log.debug("not copying %s (up-to-date)", script)
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
37 elif not self.dry_run:
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
38 with open(script, 'r') as file, open(outfile, 'w') as out:
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
39 for line in file:
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
40 if not 'pyximport' in line:
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
41 out.write(line)
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
42
226
5c5913b889bc Fix setup.py...
Thibaut Girka <thib@sitedethib.com>
parents: 219
diff changeset
43 build_scripts.copy_scripts(self)
219
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
44
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
45
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
46
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
47 for directory, _, files in os.walk('pytouhou'):
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
48 package = directory.replace(os.path.sep, '.')
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
49 packages.append(package)
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
50 for filename in files:
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
51 if filename.endswith('.pyx'):
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
52 extension_name = '%s.%s' % (package, os.path.splitext(filename)[0])
228
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
53 extension_names.append(extension_name)
418
63f59be04a54 Replace Pyglet with SDL2 for window creation and events; disables framerate control/display and sound.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 237
diff changeset
54 if extension_name == 'pytouhou.lib.sdl':
63f59be04a54 Replace Pyglet with SDL2 for window creation and events; disables framerate control/display and sound.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 237
diff changeset
55 compile_args = check_output([COMMAND, '--cflags'] + LIBRARIES).split()
63f59be04a54 Replace Pyglet with SDL2 for window creation and events; disables framerate control/display and sound.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 237
diff changeset
56 link_args = check_output([COMMAND, '--libs'] + LIBRARIES).split()
63f59be04a54 Replace Pyglet with SDL2 for window creation and events; disables framerate control/display and sound.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 237
diff changeset
57 else:
63f59be04a54 Replace Pyglet with SDL2 for window creation and events; disables framerate control/display and sound.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 237
diff changeset
58 compile_args = None
63f59be04a54 Replace Pyglet with SDL2 for window creation and events; disables framerate control/display and sound.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 237
diff changeset
59 link_args = None
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
60 extensions.append(Extension(extension_name,
418
63f59be04a54 Replace Pyglet with SDL2 for window creation and events; disables framerate control/display and sound.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 237
diff changeset
61 [os.path.join(directory, filename)],
63f59be04a54 Replace Pyglet with SDL2 for window creation and events; disables framerate control/display and sound.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 237
diff changeset
62 extra_compile_args=compile_args,
63f59be04a54 Replace Pyglet with SDL2 for window creation and events; disables framerate control/display and sound.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 237
diff changeset
63 extra_link_args=link_args))
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
64
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
65
219
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
66
228
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
67 # TODO: find a less-intrusive, cleaner way to do this...
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
68 try:
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
69 from cx_Freeze import setup, Executable
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
70 except ImportError:
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
71 extra = {}
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
72 else:
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
73 extra = {
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
74 'options': {'build_exe': {'includes': extension_names}},
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
75 'executables': [Executable(script='scripts/eosd', base='Win32GUI')]
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
76 }
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
77
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
78
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
79
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
80 setup(name='PyTouhou',
228
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
81 version="0.1",
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
82 author='Thibaut Girka',
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
83 author_email='thib@sitedethib.com',
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
84 url='http://hg.sitedethib.com/touhou/',
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
85 license='GPLv3',
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
86 packages=packages,
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
87 ext_modules=extensions,
237
cbe9dbd80dfb Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 228
diff changeset
88 scripts=['scripts/eosd', 'scripts/anmviewer'],
219
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
89 cmdclass={'build_ext': build_ext,
228
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
90 'build_scripts': BuildScripts},
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
91 **extra
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
92 )
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
93