annotate setup.py @ 411:2428296cccab

Remove indirect access to Matrix values.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 12 Jun 2013 16:07:22 +0200
parents cbe9dbd80dfb
children 63f59be04a54
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
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
9
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
10 # Cython is needed
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
11 try:
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12 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
13 except ImportError:
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14 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
15 '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
16 sys.exit(1)
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
17
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
18
228
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
19 packages = []
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
20 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
21 extensions = []
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
22
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
23
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
24
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
25 # 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
26 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
27 def copy_scripts(self):
226
5c5913b889bc Fix setup.py...
Thibaut Girka <thib@sitedethib.com>
parents: 219
diff changeset
28 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
29 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
30 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
31 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
32 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
33 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
34 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
35 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
36 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
37 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
38
226
5c5913b889bc Fix setup.py...
Thibaut Girka <thib@sitedethib.com>
parents: 219
diff changeset
39 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
40
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
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
42
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
43 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
44 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
45 packages.append(package)
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
46 for filename in files:
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
47 if filename.endswith('.pyx'):
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
48 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
49 extension_names.append(extension_name)
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
50 extensions.append(Extension(extension_name,
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
51 [os.path.join(directory, filename)]))
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
52
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
53
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
54
228
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
55 # 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
56 try:
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
57 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
58 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
59 extra = {}
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
60 else:
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
61 extra = {
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
62 '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
63 '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
64 }
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
65
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
66
8f4cd1c01d22 Add basic cx_Freeze support in order to freeze to a windows executable.
Thibaut Girka <thib@sitedethib.com>
parents: 226
diff changeset
67
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
68 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
69 version="0.1",
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
70 author='Thibaut Girka',
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
71 author_email='thib@sitedethib.com',
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
72 url='http://hg.sitedethib.com/touhou/',
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
73 license='GPLv3',
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
74 packages=packages,
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
75 ext_modules=extensions,
237
cbe9dbd80dfb Add an anmviewer script.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 228
diff changeset
76 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
77 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
78 '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
79 **extra
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
80 )
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
81