forked from nye17/javelin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
executable file
·125 lines (96 loc) · 4.15 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env python
from numpy.distutils.misc_util import Configuration
from numpy.distutils.system_info import get_info
import distutils
import shutil
import os, sys
class MyClean(distutils.command.clean.clean):
'''
Subclass to remove any files created in an inplace build.
This subclasses distutils' clean because neither setuptools nor
numpy.distutils implements a clean command.
'''
def run(self):
distutils.command.clean.clean.run(self)
# Clean any build or dist directory
if os.path.isdir("build"):
shutil.rmtree("build", ignore_errors=True)
if os.path.isdir("dist"):
shutil.rmtree("dist", ignore_errors=True)
config = Configuration('javelin',parent_package=None,top_path=None)
# finding sdist or bdist
dist = "null"
for arg in sys.argv :
if "dist" in arg :
dist = arg
# ==============================
# = Compile Fortran extensions =
# ==============================
# If optimized lapack/ BLAS libraries are present, compile distributions that involve linear algebra against those.
# Otherwise compile blas and lapack from netlib sources.
lapack_info = get_info('lapack_opt',1)
# lapack_info = get_info('',1)
# lapack_info = False
print lapack_info
# quit()
# ===========================================
# = Compile GP package's Fortran extensions =
# ===========================================
# Compile linear algebra utilities
if lapack_info:
config.add_extension(name='gp.linalg_utils',sources=['javelin/gp/linalg_utils.f','javelin/blas_wrap.f'], extra_info=lapack_info)
config.add_extension(name='gp.incomplete_chol',sources=['javelin/gp/incomplete_chol.f'], extra_info=lapack_info)
if not lapack_info or dist in ['bdist', 'sdist']:
print 'No optimized BLAS or Lapack libraries found, building from source. This may take a while...'
f_sources = ['javelin/blas_wrap.f']
for fname in os.listdir('blas/BLAS'):
if fname[-2:]=='.f':
f_sources.append('blas/BLAS/'+fname)
for fname in ['dpotrs','dpotrf','dpotf2','ilaenv','dlamch','ilaver','ieeeck','iparmq']:
f_sources.append('lapack/double/'+fname+'.f')
config.add_extension(name='gp.linalg_utils',sources=['javelin/gp/linalg_utils.f'] + f_sources)
config.add_extension(name='gp.incomplete_chol',sources=['javelin/gp/incomplete_chol.f'] + f_sources)
# Compile covariance functions
config.add_extension(name='gp.cov_funs.isotropic_cov_funs',\
sources=['javelin/gp/cov_funs/isotropic_cov_funs.f','blas/BLAS/dscal.f'],\
extra_info=lapack_info)
config.add_extension(name='gp.cov_funs.distances',sources=['javelin/gp/cov_funs/distances.f'], extra_info=lapack_info)
config.add_extension(name='spear_covfunc',sources=['javelin/spear_covfunc.f90'], extra_info=lapack_info)
config_dict = config.todict()
try:
config_dict.pop('packages')
except:
pass
if __name__ == '__main__':
from numpy.distutils.core import setup
setup( version="0.33",
description="JAVELIN: Python Version of SPEAR",
author="Ying Zu",
author_email="[email protected] ",
url="https://bitbucket.org/nye17/javelin",
license="Academic Free License",
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Operating System :: OS Independent',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: Academic Free License (AFL)',
'Programming Language :: Python',
'Programming Language :: Fortran',
'Topic :: Scientific/Engineering',
],
cmdclass = {
# Use our customized commands
'clean': MyClean,
},
requires=['NumPy (>=1.3)',],
long_description="""
Ongoing effort to combine an integral GP module to the AGN variablility study.
""",
packages=["javelin",
"javelin/gp",
"javelin/gp/cov_funs",
"javelin/emcee_internal",
],
**(config_dict)
)