annotate setup.py @ 219:091301805cce

Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
author Thibaut Girka <thib@sitedethib.com>
date Thu, 15 Dec 2011 19:24:11 +0100
parents 9634eefd2063
children 5c5913b889bc
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
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
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
20 # 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
21 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
22 def copy_scripts(self):
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
23 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
24 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
25 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
26 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
27 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
28 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
29 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
30 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
31 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
32
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 orig_build_scripts.copy_scripts(self)
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
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
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
36 packages = []
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
37 extensions = []
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
38
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
39 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
40 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
41 packages.append(package)
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
42 for filename in files:
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
43 if filename.endswith('.pyx'):
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
44 extension_name = '%s.%s' % (package, os.path.splitext(filename)[0])
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
45 extensions.append(Extension(extension_name,
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
46 [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
47
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
48
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
49
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
50 setup(name='PyTouhou',
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
51 author='Thibaut Girka',
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
52 author_email='thib@sitedethib.com',
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
53 url='http://hg.sitedethib.com/touhou/',
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
54 license='GPLv3',
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
55 packages=packages,
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
56 ext_modules=extensions,
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
57 scripts=['scripts/eosd'],
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
58 cmdclass={'build_ext': build_ext,
091301805cce Move “eclviewer.py” to “eosd” and get rid of run-time depency on Cython.
Thibaut Girka <thib@sitedethib.com>
parents: 218
diff changeset
59 'build_scripts': BuildScripts}
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
60 )
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
61