forked from bartbkr/affine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
82 lines (77 loc) · 2.49 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
76
77
78
79
80
81
82
"""
Setup for affine package
"""
import os
import sys
from setuptools import setup, Extension, find_packages
from Cython.Build import cythonize
#Package requires cython
try:
import cython
except ImportError:
nonumpy_msg = ("# cython needed to finish setup. run:\n\n" +
" $ pip install cython # or easy_install cython\n")
sys.exit(nonumpy_msg)
#Package requires numpy
try:
import numpy
except ImportError:
nonumpy_msg = ("# numpy needed to finish setup. run:\n\n" +
" $ pip install numpy # or easy_install numpy\n")
sys.exit(nonumpy_msg)
#Package requires scipy
try:
import scipy
except ImportError:
noscipy_msg = ("# scipy needed to finish setup. run:\n\n" +
" $ pip install scipy # or easy_install scipy\n")
sys.exit(noscipy_msg)
#Package requires pandas
try:
import pandas
except ImportError:
nopandas_msg = ("# pandas needed to finish setup. run:\n\n" +
" $ pip install pandas # or easy_install pandas\n")
sys.exit(nopandas_msg)
#Package requires scipy
try:
import statsmodels
except ImportError:
nostatsmodels_msg = ("# statsmodels needed to finish setup. run:\n\n" +
" $ pip install statsmodels # or easy_install statsmodels\n")
sys.exit(nostatsmodels_msg)
#Package requires tempita
try:
try:
from Cython import Tempita as tempita
except ImportError:
import tempita
except ImportError:
notempita_msg = ("# tempita needed to finish setup. run:\n\n" +
" $ pip install tempita # or easy_install tempita\n")
sys.exit(notempita_msg)
# DOC: Tempita create pyx files
code_cdir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "affine")
for folder, subdirs, files in os.walk(code_cdir):
for fil in files:
if fil.endswith(".pyx.in"):
with open(os.path.join(folder, fil), "r") as f:
cython_file = tempita.sub(f.read())
with open(os.path.join(folder, os.path.splitext(fil)[0]), "w") as f:
f.write(cython_file)
extensions = [Extension('affine.model.Cython_extensions',
['affine/extensions/Cython_extensions.pyx'])]
setup(
name='affine',
author='Barton Baker',
version='0.3',
packages=find_packages(),
description='This package offers a solver class for affine ' \
+ 'term structure models.',
author_email="bartbkr@gmail.com",
use_2to3=True,
ext_modules=cythonize(extensions),
platforms='any',
include_dirs=[numpy.get_include()],
zip_safe=False,
)