-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.py
123 lines (88 loc) · 3.33 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
#!/usr/bin/env python
from setuptools.command.install import install as setuptoolsinstall
from distutils.command.build import build as distbuild
from distutils.command.clean import clean as distclean
import os
import errno
import sys
from subprocess import call
# https://github.com/Turbo87/py-xcsoar/blob/master/setup.py
class PySCRIP_Build(distbuild):
"""
A class that
"""
def run(self):
# if sys.version_info >= (3, 0):
# F2PY = "f2py3"
# else:
# F2PY = "f2py"
F2PY = "f2py"
build_path = os.path.abspath(self.build_temp)
# os.makedirs(build_path)
try:
os.makedirs(build_path)
except OSError as exc:
if exc.errno == errno.EEXIST and os.path.isdir(build_path):
pass
# Construct the make command call
cmd = ['make', '-C', 'PySCRIP', 'F2PY='+F2PY, 'BUILDIR='+build_path]
def callmake():
call(cmd)
# Execute the make call
self.execute(callmake, [], 'Compiling SCRIP')
# copy resulting tool to library build folder
self.mkpath(self.build_lib)
if sys.version_info >= (3, 0):
fname = '_scrip.cpython-{0}{1}m-darwin.so'.format(sys.version_info[0], sys.version_info[1])
target_files = [os.path.join(build_path, fname)]
pyscriplib = "PySCRIP/{0}".format(fname)
else:
target_files = [os.path.join(build_path, '_scrip.so')]
pyscriplib = "PySCRIP/_scrip.so"
# run original build code
distbuild.run(self)
# Copy the shared library to the lib folder
self.copy_file(pyscriplib, os.path.join(self.build_lib, 'PySCRIP'))
os.remove(pyscriplib)
class PySCRIP_Install(setuptoolsinstall):
def run(self):
# do pre install stuff:
setuptoolsinstall.run(self)
# do post install stuff:
print("\nPySCRIP installed successfully\n")
class PySCRIP_Clean(distclean):
def run(self):
# Construct the make command call
cmd = ['make', 'clean', '-C', 'PySCRIP']
def callclean():
call(cmd)
# Execute the make call
self.execute(callclean, [], 'Cleaning SCRIP compilation')
distclean.run(self)
if __name__ == "__main__":
from numpy.distutils.core import setup
exec(open("PySCRIP/version.py").read())
setup(name='PySCRIP',
version=__version__,
description="Python wrapper around SCRIP",
author="Deepak Chandan",
author_email="[email protected]",
license="MIT",
classifiers=[
'Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: MIT License',
'Intended Audience :: Scientists',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
],
keywords='scrip cesm',
packages=['PySCRIP'],
cmdclass={
'build': PySCRIP_Build,
'install': PySCRIP_Install,
'clean': PySCRIP_Clean},
)