annotate setup.py @ 226:5c5913b889bc

Fix setup.py...
author Thibaut Girka <thib@sitedethib.com>
date Mon, 19 Dec 2011 22:18:11 +0100
parents 091301805cce
children 8f4cd1c01d22
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):
226
5c5913b889bc Fix setup.py...
Thibaut Girka <thib@sitedethib.com>
parents: 219
diff changeset
23 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
24 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
25 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
26 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
27 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
28 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
29 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
30 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
31 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
32 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
33
226
5c5913b889bc Fix setup.py...
Thibaut Girka <thib@sitedethib.com>
parents: 219
diff changeset
34 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
35
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
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
37 packages = []
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
38 extensions = []
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
39
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
40 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
41 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
42 packages.append(package)
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
43 for filename in files:
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
44 if filename.endswith('.pyx'):
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
45 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
46 extensions.append(Extension(extension_name,
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
47 [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
48
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
49
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
50
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
51 setup(name='PyTouhou',
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
52 author='Thibaut Girka',
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
53 author_email='thib@sitedethib.com',
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
54 url='http://hg.sitedethib.com/touhou/',
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
55 license='GPLv3',
213
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
56 packages=packages,
9bdf116bb2a5 Add a distutils setup and don’t hardcode DAT list.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
57 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
58 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
59 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
60 'build_scripts': BuildScripts}
218
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
61 )
9634eefd2063 Minor changes to the setup script
Thibaut Girka <thib@sitedethib.com>
parents: 213
diff changeset
62