-
Notifications
You must be signed in to change notification settings - Fork 9
/
setup.py
75 lines (66 loc) · 2.43 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
from numpy.distutils.core import setup, Extension
from numpy import get_include
import numpy.version
from distutils.version import StrictVersion
import generatePyCamb
import os.path
import sys
if '--nonstop' in sys.argv:
sys.argv.remove('--nonstop')
from nonstopf2py import f2py
else:
from numpy import f2py
cambsources = ['camb/%s' % f for f in [
'constants.f90',
'utils.F90',
'subroutines.f90',
'inifile.f90',
'power_tilt.f90',
'recfast.f90',
'reionization.f90',
'modules.f90',
'bessels.f90',
'equations.f90',
'halofit.f90',
'lensing.f90',
'SeparableBispectrum.F90',
'cmbmain.f90',
'camb.f90',
]]
for f in cambsources:
if not os.path.exists(f):
raise Exception("At least one of CAMB code file: '%s' is not found. Download and extract to camb/. You can use teh extract_camb.sh script to help" % f)
try: os.mkdir('src')
except: pass
generatePyCamb.main()
f2py.run_main(['-m', '_pycamb', '-h', '--overwrite-signature', 'src/py_camb_wrap.pyf',
'src/py_camb_wrap.f90', 'skip:', 'makeparameters', ':'])
# Newer versions of f2py (from numpy >= 1.6.2) use specific f90 compile args
if StrictVersion(numpy.version.version) > StrictVersion('1.6.1'):
pycamb_ext = Extension("pycamb._pycamb",
['src/py_camb_wrap.pyf'] + cambsources + ['src/py_camb_wrap.f90'],
extra_f90_compile_args=['-ffree-line-length-none','-O0', '-g', '-Dintp=npy_intp', '-fopenmp'],
libraries=['gomp'],
include_dirs=[get_include()],
)
else:
pycamb_ext = Extension("pycamb._pycamb",
['src/py_camb_wrap.pyf'] + cambsources + ['src/py_camb_wrap.f90'],
extra_compile_args=['-O0', '-g', '-Dintp=npy_intp'],
include_dirs=[get_include()],
)
# Perform setup
setup(name="pycamb", version="0.3",
author="Joe Zuntz",
author_email="[email protected]",
description="python binding of camb, you need sign agreement and obtain camb source code to build this. Thus we can not GPL this code.",
url="http://github.com/joezuntz/pycamb",
zip_safe=False,
install_requires=['numpy'],
requires=['numpy'],
packages=[ 'pycamb' ],
package_dir={'pycamb': 'src'},
data_files=[('pycamb/camb', ['camb/HighLExtrapTemplate_lenspotentialCls.dat'])],
scripts=[],
ext_modules=[pycamb_ext]
)