comparison 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
comparison
equal deleted inserted replaced
218:9634eefd2063 219:091301805cce
1 # -*- encoding: utf-8 -*- 1 # -*- encoding: utf-8 -*-
2 2
3 import os, sys 3 import os, sys
4 from distutils.core import setup 4 from distutils.core import setup
5 from distutils.extension import Extension 5 from distutils.extension import Extension
6 from distutils.command.build_scripts import build_scripts
7 from distutils.dep_util import newer
8 from distutils import log
6 9
7 10
8 # Cython is needed 11 # Cython is needed
9 try: 12 try:
10 from Cython.Distutils import build_ext 13 from Cython.Distutils import build_ext
11 except ImportError: 14 except ImportError:
12 print('You don’t seem to have Cython installed. Please get a ' 15 print('You don’t seem to have Cython installed. Please get a '
13 'copy from www.cython.org and install it') 16 'copy from www.cython.org and install it')
14 sys.exit(1) 17 sys.exit(1)
18
19
20 # The installed script shouldn't call pyximport, strip references to it
21 class BuildScripts(build_scripts):
22 def copy_scripts(self):
23 for script in (os.path.basename(script) for script in self.scripts):
24 outfile = os.path.join('scripts', script)
25 if not self.force and not newer(script, outfile):
26 log.debug("not copying %s (up-to-date)", script)
27 elif not self.dry_run:
28 with open(script, 'r') as file, open(outfile, 'w') as out:
29 for line in file:
30 if not 'pyximport' in line:
31 out.write(line)
32
33 orig_build_scripts.copy_scripts(self)
15 34
16 35
17 packages = [] 36 packages = []
18 extensions = [] 37 extensions = []
19 38
25 extension_name = '%s.%s' % (package, os.path.splitext(filename)[0]) 44 extension_name = '%s.%s' % (package, os.path.splitext(filename)[0])
26 extensions.append(Extension(extension_name, 45 extensions.append(Extension(extension_name,
27 [os.path.join(directory, filename)])) 46 [os.path.join(directory, filename)]))
28 47
29 48
49
30 setup(name='PyTouhou', 50 setup(name='PyTouhou',
31 author='Thibaut Girka', 51 author='Thibaut Girka',
32 author_email='thib@sitedethib.com', 52 author_email='thib@sitedethib.com',
33 url='http://hg.sitedethib.com/touhou/', 53 url='http://hg.sitedethib.com/touhou/',
34 license='GPLv3', 54 license='GPLv3',
35 packages=packages, 55 packages=packages,
36 ext_modules=extensions, 56 ext_modules=extensions,
37 cmdclass = {'build_ext': build_ext} 57 scripts=['scripts/eosd'],
58 cmdclass={'build_ext': build_ext,
59 'build_scripts': BuildScripts}
38 ) 60 )
39 61