forked from climlab/climlab-rrtmg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
90 lines (77 loc) · 2.99 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
import os
VERSION = '0.2'
# BEFORE importing setuptools, remove MANIFEST. Otherwise it may not be
# properly updated when the contents of directories change (true for distutils,
# not sure about setuptools).
if os.path.exists('MANIFEST'):
os.remove('MANIFEST')
def readme():
with open('README.md') as f:
return f.read()
# Patch the Fortran compiler not to optimize certain sources
def patch_fortran():
# This should work for all subclasses of FCompiler
try:
from numpy.distutils import fcompiler
except ImportError:
import sys
print("\nPlease install numpy before installing climlab\n", file=sys.stderr)
sys.exit(-1)
def monkeypatched_spawn(old_spawn):
def spawn(self, cmd, *args, **kw):
for arg in cmd:
if os.path.basename(arg) in (
'rrtmg_sw_k_g.f90',
'rrtmg_lw_k_g.f90',
):
try:
cmd.append('-O0')
except ValueError:
pass
break
return old_spawn(self, cmd, *args, **kw)
return spawn
fcompiler.FCompiler.spawn = monkeypatched_spawn(fcompiler.FCompiler.spawn)
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration(None, parent_package, top_path)
config.set_options(ignore_setup_xxx_py=True,
assume_default_configuration=True,
delegate_options_to_subpackages=True,
quiet=True)
config.add_subpackage('climlab_rrtmg')
return config
def setup_package():
__version__ = VERSION
metadata = dict(
name='climlab_rrtmg',
version=__version__,
# description='Package for process-oriented climate modeling',
# long_description=readme(),
# classifiers=[
# 'License :: OSI Approved :: MIT License',
# 'Programming Language :: Python',
# 'Intended Audience :: Education',
# 'Intended Audience :: Science/Research',
# 'Topic :: Scientific/Engineering :: Atmospheric Science',
# ],
# keywords='climate modeling modelling model ebm radiation radiative-convective earth',
# url='http://github.com/brian-rose/climlab',
# author='Brian E. J. Rose',
# author_email='brose@albany.edu',
setup_requires=['numpy'],
# install_requires=['numpy','xarray','scipy'],
license='MIT',
)
run_build = True
# This import is here because it needs to be done before importing setup()
# from numpy.distutils, but after the MANIFEST removing and sdist import
# higher up in this file.
from setuptools import setup
patch_fortran()
if run_build:
from numpy.distutils.core import setup
metadata['configuration'] = configuration
setup(**metadata)
if __name__ == '__main__':
setup_package()