-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsetup.py
More file actions
137 lines (116 loc) · 5.51 KB
/
Copy pathsetup.py
File metadata and controls
137 lines (116 loc) · 5.51 KB
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
126
127
128
129
130
131
132
133
134
135
136
137
import numpy as np
import os
import platform
import shlex
import subprocess
import sys
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
import pdb
def which(program):
"""
Mimic functionality of unix which command
"""
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
if sys.platform == "win32" and not program.endswith(".exe"):
program += ".exe"
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
if which('icpc') is not None:
os.environ['CC'] = 'icpc'
os.environ['CXX'] = 'icpc'
VERFLAGS = ['-gxx-name=g++-4.8', '-std=c++11']
CPPFLAGS = ['-O3', '-xHost', '-ip', '-parallel', '-funroll-loops', '-fno-alias', '-fno-fnalias',
'-fargument-noalias', '-fstrict-aliasing', '-ansi-alias', '-fno-stack-protector-all', '-Wall']
OMPFLAGS = ['-qopenmp', '-qopenmp-simd', '-qopt-report=5', '-qopt-report-phase=all']
OMPFLAGS = ['-qopenmp', '-qopenmp-simd', '-qopt-report=5', '-qopt-report-phase=all']
OMPLIBS = ['-liomp5']
ALIGHFLAGS = ['-falign-functions']
else:
os.environ['CC'] = 'g++'
os.environ['CXX'] = 'g++'
VERFLAGS = ['-std=c++11']
CPPFLAGS = ['-O3']
OMPFLAGS = ['-fopenmp', '-fopenmp-simd']
OMPLIBS = ['-lgomp']
ALIGHFLAGS = []
INCLUDE = os.path.join(os.environ['PWD'], 'include')
MKLFLAGS = ['-I$MKLROOT/include', '-limf']
NLOPTLIBS = ['-lnlopt']
System = platform.system()
if System == 'Linux':
MKLLIBS = ['-L$MKLROOT/lib/intel64', '-lmkl_rt', '-lpthread', '-lm', '-ldl']
elif System == 'Darwin':
if os.environ['CC'] == 'icpc':
VERFLAGS += ['-stdlib=libc++']
elif os.environ['CC'] == 'g++':
VERFLAGS = []
MKLLIBS = ['-L$MKLROOT/lib', '-Wl,-rpath,$MKLROOT/lib', '-lmkl_rt', '-lpthread', '-lm', '-ldl']
else:
MKLLIBS = []
MKLDIR = MKLLIBS[0][2:-3]
rand_sourceList = ['rand.pyx', 'rdrand.cpp']
rand_List = [os.path.join(os.environ['PWD'], 'src', srcFile) for srcFile in rand_sourceList]
rand_ext = Extension(
name='rand', sources=rand_List, language='c++',
extra_compile_args=CPPFLAGS + VERFLAGS + ALIGHFLAGS + MKLFLAGS + OMPFLAGS,
include_dirs=[INCLUDE, np.get_include()], extra_link_args=MKLLIBS + OMPLIBS + NLOPTLIBS,
library_dirs=[MKLDIR], runtime_library_dirs=[MKLDIR])
LCTools_sourceList = ['LCTools_cython.pyx', 'LC.cpp']
LCTools_List = [os.path.join(os.environ['PWD'], 'src', srcFile) for srcFile in LCTools_sourceList]
LCTools_ext = Extension(
name='LCTools_cython', sources=LCTools_List, language='c++',
extra_compile_args=CPPFLAGS + VERFLAGS + ALIGHFLAGS + MKLFLAGS + OMPFLAGS,
include_dirs=[INCLUDE, np.get_include()], extra_link_args=MKLLIBS + OMPLIBS + NLOPTLIBS,
library_dirs=[MKLDIR], runtime_library_dirs=[MKLDIR])
CARMATask_sourceList = ['rdrand.cpp', 'Constants.cpp', 'MCMC.cpp', 'CARMA.cpp', 'CARMATask.cpp',
'CARMATask_cython.pyx']
CARMATask_List = [os.path.join(os.environ['PWD'], 'src', srcFile) for srcFile in CARMATask_sourceList]
CARMATask_ext = Extension(
name='CARMATask_cython', sources=CARMATask_List, language='c++',
extra_compile_args=CPPFLAGS + VERFLAGS + ALIGHFLAGS + MKLFLAGS + OMPFLAGS,
include_dirs=[INCLUDE, np.get_include()], extra_link_args=OMPLIBS + MKLLIBS + NLOPTLIBS,
library_dirs=[MKLDIR], runtime_library_dirs=[MKLDIR])
MBHBTask_sourceList = ['rdrand.cpp', 'Constants.cpp', 'MCMC.cpp', 'MBHB.cpp', 'MBHBTask.cpp',
'MBHBTask_cython.pyx']
MBHBTask_List = [os.path.join(os.environ['PWD'], 'src', srcFile) for srcFile in MBHBTask_sourceList]
MBHBTask_ext = Extension(
name='MBHBTask_cython', sources=MBHBTask_List, language='c++',
extra_compile_args=CPPFLAGS + VERFLAGS + ALIGHFLAGS + MKLFLAGS + OMPFLAGS,
include_dirs=[INCLUDE, np.get_include()], extra_link_args=OMPLIBS + MKLLIBS + NLOPTLIBS,
library_dirs=[MKLDIR], runtime_library_dirs=[MKLDIR])
MBHBCARMATask_sourceList = ['rdrand.cpp', 'Constants.cpp', 'MCMC.cpp', 'MBHBCARMA.cpp', 'MBHBCARMATask.cpp',
'MBHBCARMATask_cython.pyx']
MBHBCARMATask_List = [os.path.join(os.environ['PWD'], 'src', srcFile) for srcFile in MBHBCARMATask_sourceList]
MBHBCARMATask_ext = Extension(
name='MBHBCARMATask_cython', sources=MBHBCARMATask_List, language='c++',
extra_compile_args=CPPFLAGS + VERFLAGS + ALIGHFLAGS + MKLFLAGS + OMPFLAGS,
include_dirs=[INCLUDE, np.get_include()], extra_link_args=OMPLIBS + MKLLIBS + NLOPTLIBS,
library_dirs=[MKLDIR], runtime_library_dirs=[MKLDIR])
setup(
name='kali',
version='2.0.0',
author='Vishal Pramod Kasliwal',
author_email='vishal.kasliwal@gmail.com',
maintainer='Vishal Pramod Kasliwal',
maintainer_email='vishal.kasliwal@gmail.com',
url='https://github.com/AstroVPK/kali',
description='Tools to study stochastic light curves',
long_description='Tools to model stochastic light curves using various stochastic process. Tools also \
include components to model MBHBs with relativistic beaming.',
download_url='https://github.com/AstroVPK/kali',
classifiers=['AGN', 'C-ARMA', 'stochastic', 'MBHBs'],
platforms=['Linux', 'Mac OSX'],
license='GNU GENERAL PUBLIC LICENSE, Version 2, June 1991',
ext_modules=cythonize([rand_ext, LCTools_ext, CARMATask_ext, MBHBTask_ext, MBHBCARMATask_ext])
)