forked from PCMDI/pcmdi_metrics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·121 lines (114 loc) · 3.77 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
from distutils.core import setup
import glob
import subprocess
import os
import sys
if "--enable-devel" in sys.argv:
install_dev = True
sys.argv.remove("--enable-devel")
else:
install_dev = False
Version = "0.6.0"
p = subprocess.Popen(
("git",
"describe",
"--tags"),
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
try:
descr = p.stdout.readlines()[0].strip()
Version = "-".join(descr.split("-")[:-2])
if Version == "":
Version = descr
except:
Version = "0.9.pre-release"
descr = Version
p = subprocess.Popen(
("git",
"log",
"-n1",
"--pretty=short"),
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
try:
commit = p.stdout.readlines()[0].split()[1]
except:
commit = ""
f = open("src/python/version.py", "w")
print >>f, "__version__ = '%s'" % Version
print >>f, "__git_tag_describe__ = '%s'" % descr
print >>f, "__git_sha1__ = '%s'" % commit
f.close()
portrait_files = ["src/python/graphics/share/portraits.scr", ]
packages = {'pcmdi_metrics': 'src/python',
'pcmdi_metrics.io': 'src/python/io',
'pcmdi_metrics.pcmdi': 'src/python/pcmdi',
'pcmdi_metrics.graphics': 'src/python/graphics',
}
scripts = ['src/python/pcmdi/scripts/pcmdi_metrics_driver.py',
'src/python/pcmdi/scripts/pcmdi_compute_climatologies.py',
'src/python/misc/scripts/install_metrics_from_branches.py',
'demo/pmp_demo_1.py',
'demo/pmp_demo.py',
]
demo_files = glob.glob("demo/*/*")
print "demo files"
data_files = [
('share/pmp/graphics/vcs', portrait_files),
('share/pmp/graphics/png', ['share/pcmdi/160915_PCMDI_logo_348x300px.png',
'share/pcmdi/160915_PCMDI_logo-oblong_377x300px.png']),
('share/pmp', ('doc/obs_info_dictionary.json',
'share/pcmdi_metrics_table',
'share/disclaimer.txt',
'share/default_regions.py')),
('share/pmp/demo',demo_files),
]
if install_dev:
print "Adding experimental packages"
dev_packages = glob.glob("src/python/devel/*")
dev_packages.remove("src/python/devel/example_dev")
for p in dev_packages:
if not os.path.isdir(p):
dev_packages.pop(p)
dev_scripts = []
for p in dev_packages:
scripts = glob.glob(os.path.join(p, "scripts", "*"))
dev_scripts += scripts
dev_pkg = {}
dev_data = []
for p in dev_packages:
nm = p.replace("/", ".")
nm = nm.replace("src.python.devel", "pcmdi_metrics")
pnm = nm.split(".")[-1]
pkg_dir = os.path.join(p, "lib")
dev_pkg[nm] = pkg_dir
data = glob.glob(os.path.join(p, "data", "*"))
for d in data:
dir_nm = os.path.split(d)[-1]
dev_data.append([os.path.join(dir_nm, pnm),
glob.glob(os.path.join(d, "*"))])
packages.update(dev_pkg)
data_files += dev_data
scripts += dev_scripts
setup(name='pcmdi_metrics',
version=descr,
author='PCMDI',
description='model metrics tools',
url='http://github.com/PCMDI/pcmdi_metrics',
packages=packages.keys(),
package_dir=packages,
scripts=scripts,
data_files=data_files
# include_dirs = [numpy.lib.utils.get_include()],
# ext_modules = [
# Extension('pcmdi_metrics.exts',
# ['src/C/add.c',],
# library_dirs = [],
# libraries = [],
# define_macros = [],
# extra_compile_args = [],
# extra_link_args = [],
# ]
)