forked from ahmed-f-alrefaie/TauREx3_public
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
193 lines (164 loc) · 6.24 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/usr/bin/env python
import setuptools
from setuptools import find_packages
from numpy.distutils.core import setup
from numpy.distutils.core import Extension
from numpy.distutils import log
import re, os
packages = find_packages(exclude=('tests', 'doc'))
provides = ['taurex', ]
requires = []
install_requires = ['numpy',
'cython',
'configobj',
'scipy',
'numba',
'astropy',
'numexpr',
'numpy',
'nestle',
'h5py',
'tabulate', ]
console_scripts = ['taurex=taurex.taurex:main',
'taurex-plot=taurex.plot.plotter:main [Plot]']
def build_ace(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration
ace_sources = ['taurex/external/ace.pyf',
'src/ACE/Md_Types_Numeriques.f90',
'src/ACE/Md_Constantes.f90',
'src/ACE/Md_numerical_recipes.f90',
'src/ACE/Md_Utilitaires.f90','src/ACE/Md_ACE.f90']
data_files = ('taurex/external/ACE', ['src/ACE/Data/NASA.therm', 'src/ACE/Data/composes.dat'])
ext = Extension(name='taurex.external.ace', sources=ace_sources)
return ext, data_files
def build_bhmie():
return Extension("taurex.external.mie",
sources=["taurex/external/bh_mie.pyx",
"src/MIE/bhmie_lib.c",
"src/MIE/complex.c",
"src/MIE/nrutil.c"
],
#extra_compile_args = [],
extra_compile_args=["-I./src/MIE/"],
language="c")
def _have_fortran_compiler():
from numpy.distutils.fcompiler import available_fcompilers_for_platform, \
new_fcompiler, \
DistutilsModuleError, \
CompilerNotFound
from numpy.distutils import customized_fcompiler
log.info('---------Detecting FORTRAN compilers-------')
try:
c = customized_fcompiler()
v = c.get_version()
return True
except (DistutilsModuleError, CompilerNotFound, AttributeError) as e:
return False
def _have_c_compiler():
from distutils.errors import DistutilsExecError, DistutilsModuleError, \
DistutilsPlatformError, CompileError
from numpy.distutils import customized_ccompiler
log.info('---------Detecting C compilers-------')
try:
c = customized_ccompiler()
v = c.get_version()
return True
except (DistutilsModuleError, CompileError, AttributeError) as e:
return False
def create_extensions():
try:
from Cython.Build import cythonize
except ImportError:
log.warn('Could not import cython, ACE chemistry')
log.warn('and BH Mie will not be installed')
return [], []
extensions = []
data_files = []
if _have_fortran_compiler():
log.info('Detected FORTRAN compiler')
log.info('ACE chemistry will be installed')
ext, dat = build_ace()
extensions.append(ext)
data_files.append(dat)
else:
log.warn('No suitable FORTRAN compiler')
log.warn('ACE chemistry will not be installed')
if _have_c_compiler():
log.info('Detected C compiler')
log.info('BH Mie will be installed')
extensions.append(build_bhmie())
else:
log.warn('No suitable C compiler')
log.warn('BH Mie will not be installed')
if len(extensions) > 0:
extensions = cythonize(extensions, language_level=3)
return extensions, data_files
extensions, data_files = create_extensions()
entry_points = {'console_scripts': console_scripts, }
classifiers = [
'Development Status :: 4 - Beta',
'Environment :: Console',
'Environment :: Win32 (MS Windows)',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Operating System :: POSIX :: Linux',
'Operating System :: Unix',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Scientific/Engineering',
'Topic :: Software Development :: Libraries',
]
# Handle versioning
version = '3.0.4-alpha'
with open("README.md", "r") as fh:
long_description = fh.read()
try:
setup(name='taurex',
author='Ahmed Faris Al-Refaie',
author_email='[email protected]',
license="BSD",
version=version,
description='TauREx 3 retrieval framework',
classifiers=classifiers,
packages=packages,
long_description=long_description,
url='https://github.com/ucl-exoplanets/TauREx3_public/',
long_description_content_type="text/markdown",
keywords = ['exoplanet','retrieval','taurex','taurex3','atmosphere','atmospheric'],
include_package_data=True,
entry_points=entry_points,
provides=provides,
requires=requires,
install_requires=install_requires,
extras_require={
'Plot': ["matplotlib"], },
data_files=data_files,
ext_modules=extensions
)
except Exception as ex:
print(str(ex))
print("The C and/or FORTRAN extension could not be compiled")
setup(name='taurex',
author='Ahmed Faris Al-Refaie',
author_email='[email protected]',
license="BSD",
version=version,
description='TauREx 3 retrieval framework',
classifiers=classifiers,
packages=packages,
long_description=long_description,
url='https://github.com/ucl-exoplanets/TauREx3_public/',
long_description_content_type="text/markdown",
keywords = ['exoplanet','retrieval','taurex','taurex3','atmosphere','atmospheric'],
include_package_data=True,
entry_points=entry_points,
provides=provides,
requires=requires,
install_requires=install_requires,
extras_require={
'Plot': ["matplotlib"], },
data_files=data_files,
)