annotate setup.py @ 574:94229756abd9

Give extra lives to the player once she has reached a certain score, and increment the default score on continue.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 26 Jul 2014 13:07:26 +0200
parents 7f113f15300b
children f3778145d7e7
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
431
77c0e9a53795 Use cythonize in setup.py, also compile .py files, and entirely remove pyximport support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 423
diff changeset
3 import os
77c0e9a53795 Use cythonize in setup.py, also compile .py files, and entirely remove pyximport support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 423
diff changeset
4 import sys
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
5 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
6 from distutils.extension import Extension
513
5e3e0b09a531 Move the OpenGL backend to its own package.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 512
diff changeset
7 from subprocess import check_output, CalledProcessError
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
8
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
9 # Cython is needed
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
10 try:
431
77c0e9a53795 Use cythonize in setup.py, also compile .py files, and entirely remove pyximport support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 423
diff changeset
11 from Cython.Build import cythonize
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12 except ImportError:
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
13 print('You don’t seem to have Cython installed. Please get a '
451
c034570ac785 Give a friendlier error message if pkg-config isn’t found.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 450
diff changeset
14 'copy from http://www.cython.org/ and install it.')
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
15 sys.exit(1)
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
17
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
18 COMMAND = 'pkg-config'
456
cae1ae9de430 Add native text support, MSG instructions 3 and 8, and text at the beginning of a stage.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 455
diff changeset
19 SDL_LIBRARIES = ['sdl2', 'SDL2_image', 'SDL2_mixer', 'SDL2_ttf']
555
98380e4a0ee5 Switch to libepoxy instead of libGLEW, which will help with OpenGL portability.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 553
diff changeset
20 GL_LIBRARIES = ['epoxy']
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
21
228
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
22 packages = []
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
23 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
24 extensions = []
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
25
521
53129f3a54af Add a debug option to enable HTML annotations, type inference display and profiling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 515
diff changeset
26 debug = False # True to generate HTML annotations and display infered types.
522
e8496e5ba056 Add a compilation option to disable anmviewer.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 521
diff changeset
27 anmviewer = False # It’s currently broken anyway.
541
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
28 nthreads = 4 # How many processes to use for Cython compilation.
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
29
542
a09f6990eab4 Add a hack to prevent `setup.py clean` from compiling Cython files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 541
diff changeset
30
a09f6990eab4 Add a hack to prevent `setup.py clean` from compiling Cython files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 541
diff changeset
31 # Hack to prevent `setup.py clean` from compiling Cython files.
a09f6990eab4 Add a hack to prevent `setup.py clean` from compiling Cython files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 541
diff changeset
32 if sys.argv[1] == 'clean':
a09f6990eab4 Add a hack to prevent `setup.py clean` from compiling Cython files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 541
diff changeset
33 import shutil
a09f6990eab4 Add a hack to prevent `setup.py clean` from compiling Cython files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 541
diff changeset
34 shutil.rmtree('build', ignore_errors=True)
a09f6990eab4 Add a hack to prevent `setup.py clean` from compiling Cython files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 541
diff changeset
35 for directory, _, files in os.walk('pytouhou'):
a09f6990eab4 Add a hack to prevent `setup.py clean` from compiling Cython files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 541
diff changeset
36 for filename in files:
a09f6990eab4 Add a hack to prevent `setup.py clean` from compiling Cython files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 541
diff changeset
37 if filename.endswith('.c'):
a09f6990eab4 Add a hack to prevent `setup.py clean` from compiling Cython files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 541
diff changeset
38 os.unlink(os.path.join(directory, filename))
a09f6990eab4 Add a hack to prevent `setup.py clean` from compiling Cython files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 541
diff changeset
39 sys.exit(0)
a09f6990eab4 Add a hack to prevent `setup.py clean` from compiling Cython files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 541
diff changeset
40
a09f6990eab4 Add a hack to prevent `setup.py clean` from compiling Cython files.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 541
diff changeset
41
562
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
42 try:
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
43 sys.argv.remove('--disable-opengl')
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
44 except ValueError:
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
45 use_opengl = True
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
46 else:
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
47 use_opengl = False
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
48
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
49
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
50 # Check for epoxy.pc, and don’t compile the OpenGL backend if it isn’t present.
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
51 if use_opengl:
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
52 try:
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
53 check_output([COMMAND] + GL_LIBRARIES)
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
54 except CalledProcessError:
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
55 print('libepoxy not found. Please install it or pass --disable-opengl')
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
56 sys.exit(1)
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
57 except OSError:
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
58 # Assume GL is here if we can’t use pkg-config, but display a warning.
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
59 print('You don’t seem to have pkg-config installed. Please get a copy '
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
60 'from http://pkg-config.freedesktop.org/ and install it.\n'
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
61 'Continuing without it, assuming every dependency is available.')
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
62
991c817d1e6b Fail when libepoxy can’t be found, pass --disable-opengl to skip the OpenGL backend compilation.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 555
diff changeset
63
541
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
64 default_libs = {
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
65 'sdl2': '-lSDL2',
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
66 'SDL2_image': '-lSDL2_image',
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
67 'SDL2_mixer': '-lSDL2_mixer',
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
68 'SDL2_ttf': '-lSDL2_ttf',
555
98380e4a0ee5 Switch to libepoxy instead of libGLEW, which will help with OpenGL portability.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 553
diff changeset
69 'epoxy': '-lepoxy'
541
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
70 }
521
53129f3a54af Add a debug option to enable HTML annotations, type inference display and profiling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 515
diff changeset
71
228
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
72
451
c034570ac785 Give a friendlier error message if pkg-config isn’t found.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 450
diff changeset
73 def get_arguments(arg, libraries):
c034570ac785 Give a friendlier error message if pkg-config isn’t found.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 450
diff changeset
74 try:
c034570ac785 Give a friendlier error message if pkg-config isn’t found.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 450
diff changeset
75 return check_output([COMMAND, arg] + libraries).split()
513
5e3e0b09a531 Move the OpenGL backend to its own package.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 512
diff changeset
76 except CalledProcessError:
5e3e0b09a531 Move the OpenGL backend to its own package.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 512
diff changeset
77 # The error has already been displayed, just exit.
5e3e0b09a531 Move the OpenGL backend to its own package.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 512
diff changeset
78 sys.exit(1)
451
c034570ac785 Give a friendlier error message if pkg-config isn’t found.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 450
diff changeset
79 except OSError:
541
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
80 # We already said to the user pkg-config was suggested.
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
81 if arg == '--cflags':
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
82 return []
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
83 return [default_libs[library] for library in libraries]
451
c034570ac785 Give a friendlier error message if pkg-config isn’t found.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 450
diff changeset
84
c034570ac785 Give a friendlier error message if pkg-config isn’t found.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 450
diff changeset
85
541
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
86 sdl_args = {'extra_compile_args': get_arguments('--cflags', SDL_LIBRARIES),
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
87 'extra_link_args': get_arguments('--libs', SDL_LIBRARIES)}
513
5e3e0b09a531 Move the OpenGL backend to its own package.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 512
diff changeset
88
541
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
89 if use_opengl:
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
90 opengl_args = {'extra_compile_args': get_arguments('--cflags', GL_LIBRARIES + SDL_LIBRARIES),
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
91 'extra_link_args': get_arguments('--libs', GL_LIBRARIES + SDL_LIBRARIES)}
513
5e3e0b09a531 Move the OpenGL backend to its own package.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 512
diff changeset
92
5e3e0b09a531 Move the OpenGL backend to its own package.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 512
diff changeset
93
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
94 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
95 package = directory.replace(os.path.sep, '.')
541
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
96 if not use_opengl and package in ('pytouhou.ui.opengl', 'pytouhou.ui.opengl.shaders'):
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
97 continue
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
98 packages.append(package)
541
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
99 if package not in ('pytouhou.formats', 'pytouhou.game', 'pytouhou.lib',
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
100 'pytouhou.utils', 'pytouhou.ui', 'pytouhou.ui.opengl',
563
ab0a5580bc40 Fix Windows build, the shaders package was skipped.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 562
diff changeset
101 'pytouhou.ui.opengl.shaders', 'pytouhou.ui.sdl'):
488
791faab05445 Don’t compile files that don’t benefit from static typing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 460
diff changeset
102 continue
541
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
103 if package in ('pytouhou.ui', 'pytouhou.ui.sdl'):
513
5e3e0b09a531 Move the OpenGL backend to its own package.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 512
diff changeset
104 package_args = sdl_args
5e3e0b09a531 Move the OpenGL backend to its own package.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 512
diff changeset
105 elif package == 'pytouhou.ui.opengl':
5e3e0b09a531 Move the OpenGL backend to its own package.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 512
diff changeset
106 package_args = opengl_args
488
791faab05445 Don’t compile files that don’t benefit from static typing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 460
diff changeset
107 else:
513
5e3e0b09a531 Move the OpenGL backend to its own package.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 512
diff changeset
108 package_args = {}
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
109 for filename in files:
488
791faab05445 Don’t compile files that don’t benefit from static typing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 460
diff changeset
110 if (filename.endswith('.pyx') or filename.endswith('.py') and
791faab05445 Don’t compile files that don’t benefit from static typing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 460
diff changeset
111 not filename == '__init__.py'):
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
112 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
113 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
114 if extension_name == 'pytouhou.lib.sdl':
513
5e3e0b09a531 Move the OpenGL backend to its own package.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 512
diff changeset
115 compile_args = sdl_args
522
e8496e5ba056 Add a compilation option to disable anmviewer.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 521
diff changeset
116 elif extension_name == 'pytouhou.ui.anmrenderer' and not anmviewer:
541
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
117 extension_names.pop()
522
e8496e5ba056 Add a compilation option to disable anmviewer.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 521
diff changeset
118 continue
525
43ecf0f98f4d Precalculate the inverse of the texture size at ANM load, to not recalculate at every sprite change.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 522
diff changeset
119 elif package == 'pytouhou.formats' and extension_name != 'pytouhou.formats.anm0':
43ecf0f98f4d Precalculate the inverse of the texture size at ANM load, to not recalculate at every sprite change.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 522
diff changeset
120 continue
513
5e3e0b09a531 Move the OpenGL backend to its own package.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 512
diff changeset
121 else:
5e3e0b09a531 Move the OpenGL backend to its own package.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 512
diff changeset
122 compile_args = package_args
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
123 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
124 [os.path.join(directory, filename)],
513
5e3e0b09a531 Move the OpenGL backend to its own package.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 512
diff changeset
125 **compile_args))
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
126
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
127
541
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
128 # OS-specific setuptools options.
228
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
129 try:
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
130 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
131 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
132 extra = {}
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
133 else:
541
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
134 nthreads = None # It seems Windows can’t compile in parallel.
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
135 base = 'Win32GUI' if sys.platform == 'win32' else None
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
136 extra = {'options': {'build_exe': {'includes': extension_names + ['glob', 'socket', 'select']}},
546
94dd9862c470 Rename the eosd script into pytouhou, and remove the obsolete pcb one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 542
diff changeset
137 'executables': [Executable(script='scripts/pytouhou', base=base)]}
228
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
138
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
139
572
7f113f15300b Include the Glade file in the main package on install.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 563
diff changeset
140 # Create a link to the data files (for packaging purposes)
7f113f15300b Include the Glade file in the main package on install.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 563
diff changeset
141 current_dir = os.path.dirname(os.path.realpath(__file__))
7f113f15300b Include the Glade file in the main package on install.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 563
diff changeset
142 temp_data_dir = os.path.join(current_dir, 'pytouhou', 'data')
7f113f15300b Include the Glade file in the main package on install.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 563
diff changeset
143 if not os.path.exists(temp_data_dir):
7f113f15300b Include the Glade file in the main package on install.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 563
diff changeset
144 os.symlink(os.path.join(current_dir, 'data'), temp_data_dir)
7f113f15300b Include the Glade file in the main package on install.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 563
diff changeset
145
7f113f15300b Include the Glade file in the main package on install.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 563
diff changeset
146
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
147 setup(name='PyTouhou',
431
77c0e9a53795 Use cythonize in setup.py, also compile .py files, and entirely remove pyximport support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 423
diff changeset
148 version='0.1',
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
149 author='Thibaut Girka',
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
150 author_email='thib@sitedethib.com',
431
77c0e9a53795 Use cythonize in setup.py, also compile .py files, and entirely remove pyximport support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 423
diff changeset
151 url='http://pytouhou.linkmauve.fr/',
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
152 license='GPLv3',
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
153 packages=packages,
541
8895ede4e51e Fix Windows and OSX build by making pkg-config optional and assuming every dependency is available.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 528
diff changeset
154 ext_modules=cythonize(extensions, nthreads=nthreads, annotate=debug,
431
77c0e9a53795 Use cythonize in setup.py, also compile .py files, and entirely remove pyximport support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 423
diff changeset
155 compiler_directives={'infer_types': True,
521
53129f3a54af Add a debug option to enable HTML annotations, type inference display and profiling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 515
diff changeset
156 'infer_types.verbose': debug,
53129f3a54af Add a debug option to enable HTML annotations, type inference display and profiling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 515
diff changeset
157 'profile': debug},
515
b3193b43a86c Add an indirection layer for textures, to cope with drivers assigning them random names.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 513
diff changeset
158 compile_time_env={'MAX_TEXTURES': 128,
505
bfea9e9a6845 Manage the texture-specific indices in the Texture, and some more renderer optimisations.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 488
diff changeset
159 'MAX_ELEMENTS': 640 * 4 * 3,
528
7c3c90468996 Inherit music players from a base class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 525
diff changeset
160 'MAX_SOUNDS': 26,
555
98380e4a0ee5 Switch to libepoxy instead of libGLEW, which will help with OpenGL portability.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 553
diff changeset
161 'USE_OPENGL': use_opengl}),
546
94dd9862c470 Rename the eosd script into pytouhou, and remove the obsolete pcb one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 542
diff changeset
162 scripts=['scripts/pytouhou'] + (['scripts/anmviewer'] if anmviewer else []),
572
7f113f15300b Include the Glade file in the main package on install.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 563
diff changeset
163 package_data={'pytouhou': ['data/menu.glade']},
431
77c0e9a53795 Use cythonize in setup.py, also compile .py files, and entirely remove pyximport support.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 423
diff changeset
164 **extra)
572
7f113f15300b Include the Glade file in the main package on install.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 563
diff changeset
165
7f113f15300b Include the Glade file in the main package on install.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 563
diff changeset
166
7f113f15300b Include the Glade file in the main package on install.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 563
diff changeset
167 # Remove the link afterwards
7f113f15300b Include the Glade file in the main package on install.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 563
diff changeset
168 if os.path.exists(temp_data_dir):
7f113f15300b Include the Glade file in the main package on install.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 563
diff changeset
169 os.unlink(temp_data_dir)