-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
51 lines (45 loc) · 1.89 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from setuptools import setup, find_packages, Extension
import versioneer
import sys
import os
mako_templates=[(os.path.join('cyinterval', 'cyinterval.mako.pyx'), os.path.join('cyinterval', 'cyinterval.pyx')),
(os.path.join('cyinterval', 'cyinterval.mako.pxd'), os.path.join('cyinterval', 'cyinterval.pxd'))]
if '--makoize' in sys.argv:
from mako.lookup import TemplateLookup
del sys.argv[sys.argv.index('--makoize')]
lookup = TemplateLookup(directories = ['.'])
for template_file, target_file in mako_templates:
template = lookup.get_template(template_file)
with open(target_file, 'w') as outfile:
outfile.write(template.render())
# Determine whether to use Cython
if '--cythonize' in sys.argv:
from Cython.Build.Dependencies import cythonize
from Cython.Distutils import build_ext
cythonize_switch = True
del sys.argv[sys.argv.index('--cythonize')]
ext = 'pyx'
directives = {}
directives['linetrace'] = False
directives['binding'] = False
directives['profile'] = False
cmdclass = {'build_ext': build_ext}
else:
from setuptools.command.build_ext import build_ext # @NoMove @Reimport
cythonize_switch = False
ext = 'c'
cmdclass = {'build_ext': build_ext}
ext_modules = [Extension('cyinterval.cyinterval',
[os.path.join('cyinterval',
'cyinterval.%s' % ext)])]
setup(name='cyinterval',
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(cmdclass),
author='Jason Rudy',
author_email='[email protected]',
url='https://github.com/jcrudy/cyinterval',
packages=find_packages(),
package_data={'cyinterval': ['cyinterval.pxd', 'cyinterval.pyx']},
ext_modules = cythonize(ext_modules, compiler_directives=directives) if cythonize_switch else ext_modules,
install_requires=[]
)