Mercurial > touhou
annotate setup.py @ 429:40d5f3083ebc
Implement PCB’s ANM2 format and vm.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 03 Aug 2013 15:48:57 +0200 |
parents | d8630c086926 |
children | 77c0e9a53795 |
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' |
421
b1248bab2d0f
Add back music and SFX playback using SDL_mixer instead of pyglet, and add FLAC and Vorbis support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
420
diff
changeset
|
21 LIBRARIES = ['sdl2', 'SDL2_image', 'SDL2_mixer'] |
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
|
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 | 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 | 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() |
423
d8630c086926
Replace Pyglet with our own Cython OpenGL wrapper.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
421
diff
changeset
|
57 elif extension_name.startswith('pytouhou.ui.'): #XXX |
d8630c086926
Replace Pyglet with our own Cython OpenGL wrapper.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
421
diff
changeset
|
58 compile_args = check_output([COMMAND, '--cflags', 'gl']).split() |
d8630c086926
Replace Pyglet with our own Cython OpenGL wrapper.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
421
diff
changeset
|
59 link_args = check_output([COMMAND, '--libs', 'gl']).split() |
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
|
60 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
|
61 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
|
62 link_args = None |
218
9634eefd2063
Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents:
213
diff
changeset
|
63 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
|
64 [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
|
65 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
|
66 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
|
67 |
9bdf116bb2a5
Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
68 |
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
|
69 |
228
8f4cd1c01d22
Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents:
226
diff
changeset
|
70 # 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
|
71 try: |
8f4cd1c01d22
Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents:
226
diff
changeset
|
72 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
|
73 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
|
74 extra = {} |
8f4cd1c01d22
Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents:
226
diff
changeset
|
75 else: |
8f4cd1c01d22
Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents:
226
diff
changeset
|
76 extra = { |
8f4cd1c01d22
Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents:
226
diff
changeset
|
77 '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
|
78 '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
|
79 } |
8f4cd1c01d22
Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents:
226
diff
changeset
|
80 |
8f4cd1c01d22
Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents:
226
diff
changeset
|
81 |
8f4cd1c01d22
Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents:
226
diff
changeset
|
82 |
213
9bdf116bb2a5
Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
83 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
|
84 version="0.1", |
218
9634eefd2063
Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents:
213
diff
changeset
|
85 author='Thibaut Girka', |
9634eefd2063
Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents:
213
diff
changeset
|
86 author_email='thib@sitedethib.com', |
9634eefd2063
Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents:
213
diff
changeset
|
87 url='http://hg.sitedethib.com/touhou/', |
9634eefd2063
Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents:
213
diff
changeset
|
88 license='GPLv3', |
213
9bdf116bb2a5
Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
89 packages=packages, |
9bdf116bb2a5
Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
90 ext_modules=extensions, |
237
cbe9dbd80dfb
Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
228
diff
changeset
|
91 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
|
92 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
|
93 '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
|
94 **extra |
218
9634eefd2063
Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents:
213
diff
changeset
|
95 ) |
9634eefd2063
Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents:
213
diff
changeset
|
96 |