Mercurial > touhou
annotate setup.py @ 505:bfea9e9a6845
Manage the texture-specific indices in the Texture, and some more renderer optimisations.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 01 Nov 2013 14:45:53 +0100 |
parents | 791faab05445 |
children | 08d9e6730364 |
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 |
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
|
7 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
|
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'] |
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 |
228
8f4cd1c01d22
Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents:
226
diff
changeset
|
21 packages = [] |
8f4cd1c01d22
Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents:
226
diff
changeset
|
22 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
|
23 extensions = [] |
8f4cd1c01d22
Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents:
226
diff
changeset
|
24 |
8f4cd1c01d22
Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents:
226
diff
changeset
|
25 |
451
c034570ac785
Give a friendlier error message if pkg-config isn’t found.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
450
diff
changeset
|
26 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
|
27 try: |
c034570ac785
Give a friendlier error message if pkg-config isn’t found.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
450
diff
changeset
|
28 return check_output([COMMAND, arg] + libraries).split() |
c034570ac785
Give a friendlier error message if pkg-config isn’t found.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
450
diff
changeset
|
29 except OSError: |
c034570ac785
Give a friendlier error message if pkg-config isn’t found.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
450
diff
changeset
|
30 print('You don’t seem to have pkg-config installed. Please get a copy ' |
c034570ac785
Give a friendlier error message if pkg-config isn’t found.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
450
diff
changeset
|
31 'from http://pkg-config.freedesktop.org/ and install it.\n' |
c034570ac785
Give a friendlier error message if pkg-config isn’t found.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
450
diff
changeset
|
32 'If you prefer to use it from somewhere else, just modify the ' |
c034570ac785
Give a friendlier error message if pkg-config isn’t found.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
450
diff
changeset
|
33 'setup.py script.') |
c034570ac785
Give a friendlier error message if pkg-config isn’t found.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
450
diff
changeset
|
34 sys.exit(1) |
c034570ac785
Give a friendlier error message if pkg-config isn’t found.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
450
diff
changeset
|
35 |
c034570ac785
Give a friendlier error message if pkg-config isn’t found.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
450
diff
changeset
|
36 |
213
9bdf116bb2a5
Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
37 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
|
38 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
|
39 packages.append(package) |
488
791faab05445
Don’t compile files that don’t benefit from static typing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
460
diff
changeset
|
40 if (package == 'pytouhou.formats' or package == 'pytouhou.vm'): |
791faab05445
Don’t compile files that don’t benefit from static typing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
460
diff
changeset
|
41 continue |
791faab05445
Don’t compile files that don’t benefit from static typing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
460
diff
changeset
|
42 if package == 'pytouhou.ui': |
791faab05445
Don’t compile files that don’t benefit from static typing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
460
diff
changeset
|
43 compile_args = get_arguments('--cflags', ['gl'] + SDL_LIBRARIES) |
791faab05445
Don’t compile files that don’t benefit from static typing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
460
diff
changeset
|
44 link_args = get_arguments('--libs', ['gl'] + SDL_LIBRARIES) |
791faab05445
Don’t compile files that don’t benefit from static typing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
460
diff
changeset
|
45 else: |
791faab05445
Don’t compile files that don’t benefit from static typing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
460
diff
changeset
|
46 compile_args = None |
791faab05445
Don’t compile files that don’t benefit from static typing.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
460
diff
changeset
|
47 link_args = None |
213
9bdf116bb2a5
Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
48 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
|
49 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
|
50 not filename == '__init__.py'): |
218
9634eefd2063
Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents:
213
diff
changeset
|
51 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
|
52 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
|
53 if extension_name == 'pytouhou.lib.sdl': |
451
c034570ac785
Give a friendlier error message if pkg-config isn’t found.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
450
diff
changeset
|
54 compile_args = get_arguments('--cflags', SDL_LIBRARIES) |
c034570ac785
Give a friendlier error message if pkg-config isn’t found.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
450
diff
changeset
|
55 link_args = get_arguments('--libs', SDL_LIBRARIES) |
218
9634eefd2063
Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents:
213
diff
changeset
|
56 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
|
57 [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
|
58 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
|
59 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
|
60 |
9bdf116bb2a5
Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
61 |
228
8f4cd1c01d22
Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents:
226
diff
changeset
|
62 # 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
|
63 try: |
8f4cd1c01d22
Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents:
226
diff
changeset
|
64 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
|
65 except ImportError: |
450
2a352118c55a
Add back Windows support, using GLEW for OpenGL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
449
diff
changeset
|
66 is_windows = False |
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 extra = {} |
8f4cd1c01d22
Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents:
226
diff
changeset
|
68 else: |
450
2a352118c55a
Add back Windows support, using GLEW for OpenGL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
449
diff
changeset
|
69 is_windows = True |
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
|
70 extra = {'options': {'build_exe': {'includes': extension_names}}, |
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
|
71 'executables': [Executable(script='eosd', base='Win32GUI')]} |
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 |
8f4cd1c01d22
Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents:
226
diff
changeset
|
73 |
213
9bdf116bb2a5
Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
74 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
|
75 version='0.1', |
218
9634eefd2063
Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents:
213
diff
changeset
|
76 author='Thibaut Girka', |
9634eefd2063
Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents:
213
diff
changeset
|
77 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
|
78 url='http://pytouhou.linkmauve.fr/', |
218
9634eefd2063
Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents:
213
diff
changeset
|
79 license='GPLv3', |
213
9bdf116bb2a5
Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
80 packages=packages, |
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
|
81 ext_modules=cythonize(extensions, nthreads=4, |
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
|
82 compiler_directives={'infer_types': True, |
449
d56536ef28e8
Improve render_elements’ speed a lot, and fix it in some corner cases. Thanks liori!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
431
diff
changeset
|
83 'infer_types.verbose': True}, |
450
2a352118c55a
Add back Windows support, using GLEW for OpenGL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
449
diff
changeset
|
84 compile_time_env={'MAX_TEXTURES': 1024, |
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
|
85 'MAX_ELEMENTS': 640 * 4 * 3, |
460
ec327e58b477
Add a context manager to initialize and shut down SDL outside of Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
456
diff
changeset
|
86 'MAX_CHANNELS': 26, |
450
2a352118c55a
Add back Windows support, using GLEW for OpenGL.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
449
diff
changeset
|
87 'USE_GLEW': is_windows}), |
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
|
88 scripts=['eosd', 'anmviewer'], |
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
|
89 **extra) |