-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsetup.py
executable file
·75 lines (63 loc) · 2.18 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/python
"""A setuptools-based script for distributing and installing bandmat."""
# Copyright 2013, 2014, 2015, 2016, 2017, 2018 Matt Shannon
# This file is part of bandmat.
# See `License` for details of license and warranty.
import os
import numpy as np
from setuptools import setup
from setuptools.extension import Extension
from setuptools.command.sdist import sdist as _sdist
cython_locs = [
('bandmat', 'full'),
('bandmat', 'core'),
('bandmat', 'tensor'),
('bandmat', 'linalg'),
('bandmat', 'misc'),
('bandmat', 'overlap'),
]
with open('README.rst') as readme_file:
long_description = readme_file.read()
requires = [ line.rstrip('\n') for line in open('requirements.txt') ]
# see "A note on setup.py" in README.rst for an explanation of the dev file
dev_mode = os.path.exists('dev')
if dev_mode:
from Cython.Distutils import build_ext
from Cython.Build import cythonize
class sdist(_sdist):
"""A cythonizing sdist command.
This class is a custom sdist command which ensures all cython-generated
C files are up-to-date before running the conventional sdist command.
"""
def run(self):
cythonize([ os.path.join(*loc)+'.pyx' for loc in cython_locs ])
_sdist.run(self)
cmdclass = {'build_ext': build_ext, 'sdist': sdist}
ext_modules = [
Extension('.'.join(loc), [os.path.join(*loc)+'.pyx'],
extra_compile_args=['-O3'],
include_dirs=[np.get_include()])
for loc in cython_locs
]
else:
cmdclass = {}
ext_modules = [
Extension('.'.join(loc), [os.path.join(*loc)+'.c'],
extra_compile_args=['-O3'],
include_dirs=[np.get_include()])
for loc in cython_locs
]
setup(
name='bandmat',
version='0.8.dev1',
description='A banded matrix library for python.',
url='http://github.com/MattShannon/bandmat',
author='Matt Shannon',
author_email='matt.shannon@cantab.net',
license='3-clause BSD (see License file)',
packages=['bandmat'],
install_requires=requires,
long_description=long_description,
cmdclass=cmdclass,
ext_modules=ext_modules,
)