forked from numpy/numpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bscript
132 lines (107 loc) · 4.34 KB
/
bscript
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
"""
See BENTO_BUILD.txt.
Caveats:
- no automatic detection for BLAS/LAPACK/etc... You need to set it up
manually for now (except on Mac OS X and Debian/Ubuntu). The upside is
that it is extremely easy to do so
- bento is still in flux, and some things may changes between releases.
"""
import os
import sys
import subprocess
import string
import os.path as op
# Ugly but necessary hack: import numpy here so that wscript in sub directories
# will see this numpy and not an already installed one
import __builtin__
__builtin__.__NUMPY_SETUP__ = True
from bento.commands import hooks
import waflib
sys.path.insert(0, os.getcwd())
try:
_SETUP_PY = __import__("setup")
finally:
sys.path.pop(0)
def check_blas_lapack(conf):
conf.env.HAS_CBLAS = False
if sys.platform == "win32":
mkl_libs = "mkl_lapack95,mkl_blas95,mkl_intel_c,mkl_intel_thread,mkl_core,libiomp5md".split(",")
mkl_base = r"C:\Program Files\Intel\Compiler\11.1\051"
conf.env.INCLUDES.append("%s\mkl\include" % mkl_base)
conf.env.LIBPATH.extend(["%s\mkl\ia32\lib" % mkl_base,
"%s\lib\ia32" % mkl_base])
try:
conf.check_cc(lib=mkl_libs, msg="Checking for MKL (CBLAS)",
uselib_store="CBLAS")
conf.env.HAS_CBLAS = True
conf.check_cc(lib=mkl_libs, msg="Checking for MKL (LAPACK)",
uselib_store="LAPACK")
conf.env.HAS_LAPACK = True
except waflib.Errors.ConfigurationError:
pass
elif sys.platform == "darwin":
try:
conf.check(framework="Accelerate", msg="Checking for framework Accelerate", uselib_store="CBLAS")
conf.env.HAS_CBLAS = True
conf.check(framework="Accelerate", msg="Checking for framework Accelerate", uselib_store="LAPACK")
conf.env.HAS_LAPACK = True
except waflib.Errors.ConfigurationError:
pass
else:
try:
conf.check_cc(lib=["cblas", "atlas"], uselib_store="CBLAS")
conf.env.HAS_CBLAS = True
conf.check_cc(lib=["lapack", "f77blas", "cblas", "atlas"],
uselib_store="LAPACK")
conf.env.HAS_LAPACK = True
except waflib.Errors.ConfigurationError:
pass
# You can manually set up blas/lapack as follows:
#conf.env.HAS_CBLAS = True
#conf.env.LIB_CBLAS = ["cblas", "atlas"]
#conf.env.HAS_LAPACK = True
#conf.env.LIB_LAPACK = ["lapack", "f77blas", "cblas", "atlas"]
def set_revision(template, version):
try:
proc = subprocess.Popen('git rev-parse --short HEAD',
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True)
git_revision, _ = proc.communicate()
git_revision = git_revision.strip()
except Exception:
git_revision = "Unknown"
full_version = version
template_str = template.read()
if not _SETUP_PY.ISRELEASED:
full_version += '.dev-' + git_revision[:7]
content = string.Template(template_str).substitute(version=version,
full_version=full_version, git_revision=git_revision,
is_released=_SETUP_PY.ISRELEASED)
output = template.change_ext("")
output.safe_write(content)
return output
def make_git_commit_info(ctx):
commit_template = ctx.make_source_node(op.join("numpy", "version.py.in"))
return set_revision(commit_template, ctx.pkg.version)
@hooks.pre_configure
def pre_configure(context):
conf = context.waf_context
conf.load("compiler_c")
conf.load("python")
conf.check_python_version((2, 4, 0))
conf.check_python_headers()
if conf.env["CC_NAME"] == "gcc":
conf.env.CFLAGS_PYEXT.append("-Wfatal-errors")
check_blas_lapack(conf)
@hooks.pre_build
def pre_build(context):
context.register_category("git_info")
commit_output = make_git_commit_info(context)
context.register_outputs("git_info", "git_commit_info", [commit_output])
# FIXME: we write a dummy show for now - the original show function is not
# super useful anyway.
context.register_category("gen_config")
config_node = context.make_build_node("numpy/__config__.py")
config_node.safe_write("def show(): pass")
context.register_outputs("gen_config", "top_config", [config_node])