forked from climlab/climlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
93 lines (77 loc) · 3.02 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
import os, sys
import textwrap
VERSION = '0.7.2.dev0'
# 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.rst') as f:
return f.read()
# Patch the GNU Fortran compiler not to optimize certain sources
def patch_gnu_fortran():
from numpy.distutils.fcompiler import gnu
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
gnu.GnuFCompiler.spawn = monkeypatched_spawn(gnu.GnuFCompiler.spawn)
gnu.Gnu95FCompiler.spawn = monkeypatched_spawn(gnu.Gnu95FCompiler.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')
#config.get_version('numpy/version.py') # sets config.version
return config
def setup_package():
__version__ = VERSION
metadata = dict(
name='climlab',
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='[email protected]',
license='MIT',
)
# if "--force" in sys.argv:
# run_build = True
# else:
# # Raise errors for unsupported commands, improve help output, etc.
# run_build = parse_setuppy_commands()
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_gnu_fortran()
if run_build:
from numpy.distutils.core import setup
metadata['configuration'] = configuration
setup(**metadata)
if __name__ == '__main__':
setup_package()