🌐 AI搜索 & 代理 主页
blob: 88f434d7f262a015de1ad98c7a7d9ac8aec5a13a [file] [log] [blame]
David Cournapeau3763b572011-08-27 22:25:141"""
David Cournapeauda2af082011-09-08 15:31:122See BENTO_BUILD.txt.
David Cournapeau3763b572011-08-27 22:25:143
4Caveats:
5
6 - no automatic detection for BLAS/LAPACK/etc... You need to set it up
7 manually for now (except on Mac OS X and Debian/Ubuntu). The upside is
8 that it is extremely easy to do so
9 - bento is still in flux, and some things may changes between releases.
David Cournapeau3763b572011-08-27 22:25:1410"""
11
David Cournapeau78470432011-05-30 00:10:3512import os
David Cournapeaud2f648a2011-03-07 00:02:3213import sys
David Cournapeau7f302cc2011-11-21 06:03:4414import subprocess
15import string
16
17import os.path as op
David Cournapeaud2f648a2011-03-07 00:02:3218
David Cournapeau0c7af4b2011-03-07 00:30:4219# Ugly but necessary hack: import numpy here so that wscript in sub directories
20# will see this numpy and not an already installed one
21import __builtin__
22__builtin__.__NUMPY_SETUP__ = True
23
David Cournapeaua52f88f2011-04-06 00:18:0424from bento.commands import hooks
David Cournapeau6fe584f2012-06-11 10:14:5825from bento.utils.utils \
26 import \
27 cmd_is_runnable
David Cournapeaud2f648a2011-03-07 00:02:3228
David Cournapeauaa7e9bd2011-03-15 15:39:1529import waflib
30
David Cournapeau7f302cc2011-11-21 06:03:4431sys.path.insert(0, os.getcwd())
32try:
33 _SETUP_PY = __import__("setup")
34finally:
35 sys.path.pop(0)
36
David Cournapeaud2f648a2011-03-07 00:02:3237def check_blas_lapack(conf):
38 conf.env.HAS_CBLAS = False
39 if sys.platform == "win32":
David Cournapeau7129d902011-08-26 11:43:3840 mkl_libs = "mkl_lapack95,mkl_blas95,mkl_intel_c,mkl_intel_thread,mkl_core,libiomp5md".split(",")
41 mkl_base = r"C:\Program Files\Intel\Compiler\11.1\051"
42 conf.env.INCLUDES.append("%s\mkl\include" % mkl_base)
43 conf.env.LIBPATH.extend(["%s\mkl\ia32\lib" % mkl_base,
44 "%s\lib\ia32" % mkl_base])
45
46 try:
47 conf.check_cc(lib=mkl_libs, msg="Checking for MKL (CBLAS)",
48 uselib_store="CBLAS")
49 conf.env.HAS_CBLAS = True
David Cournapeaufd785462012-05-31 15:14:1450 except waflib.Errors.ConfigurationError:
51 conf.env.HAS_LAPACK = False
David Cournapeau7129d902011-08-26 11:43:3852
David Cournapeaufd785462012-05-31 15:14:1453 try:
David Cournapeau7129d902011-08-26 11:43:3854 conf.check_cc(lib=mkl_libs, msg="Checking for MKL (LAPACK)",
55 uselib_store="LAPACK")
56 conf.env.HAS_LAPACK = True
57 except waflib.Errors.ConfigurationError:
David Cournapeaufd785462012-05-31 15:14:1458 conf.env.HAS_LAPACK = False
59
David Cournapeau7129d902011-08-26 11:43:3860
David Cournapeaud2f648a2011-03-07 00:02:3261 elif sys.platform == "darwin":
62 try:
David Cournapeaufd785462012-05-31 15:14:1463 conf.check(framework="Accelerate", msg="Checking for framework Accelerate (CBLAS)", uselib_store="CBLAS")
David Cournapeaud2f648a2011-03-07 00:02:3264 conf.env.HAS_CBLAS = True
David Cournapeaufd785462012-05-31 15:14:1465 except waflib.Errors.ConfigurationError:
66 conf.env.HAS_CBLAS = False
David Cournapeaud2f648a2011-03-07 00:02:3267
David Cournapeaufd785462012-05-31 15:14:1468 try:
69 conf.check(framework="Accelerate", msg="Checking for framework Accelerate (LAPACK)", uselib_store="LAPACK")
David Cournapeaud2f648a2011-03-07 00:02:3270 conf.env.HAS_LAPACK = True
71 except waflib.Errors.ConfigurationError:
David Cournapeaufd785462012-05-31 15:14:1472 conf.env.HAS_LAPACK = False
David Cournapeaud2f648a2011-03-07 00:02:3273 else:
74 try:
75 conf.check_cc(lib=["cblas", "atlas"], uselib_store="CBLAS")
76 conf.env.HAS_CBLAS = True
David Cournapeaufd785462012-05-31 15:14:1477 except waflib.Errors.ConfigurationError:
78 conf.env.HAS_CBLAS = False
David Cournapeaud2f648a2011-03-07 00:02:3279
David Cournapeaufd785462012-05-31 15:14:1480 try:
David Cournapeaud2f648a2011-03-07 00:02:3281 conf.check_cc(lib=["lapack", "f77blas", "cblas", "atlas"],
82 uselib_store="LAPACK")
83 conf.env.HAS_LAPACK = True
84 except waflib.Errors.ConfigurationError:
David Cournapeaufd785462012-05-31 15:14:1485 conf.env.HAS_LAPACK = False
David Cournapeaud2f648a2011-03-07 00:02:3286
87 # You can manually set up blas/lapack as follows:
88 #conf.env.HAS_CBLAS = True
89 #conf.env.LIB_CBLAS = ["cblas", "atlas"]
90 #conf.env.HAS_LAPACK = True
91 #conf.env.LIB_LAPACK = ["lapack", "f77blas", "cblas", "atlas"]
92
David Cournapeau6fe584f2012-06-11 10:14:5893def compute_git_revision(top_node):
94 git_repo_node = top_node.find_node(".git")
95 if git_repo_node and cmd_is_runnable(["git", "--version"]):
96 s = subprocess.Popen(["git", "rev-parse", "HEAD"],
97 stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=top_node.abspath())
98 out = s.communicate()[0]
99 return out.decode().strip()
100 else:
101 return ""
David Cournapeau7f302cc2011-11-21 06:03:44102
David Cournapeau6fe584f2012-06-11 10:14:58103def _register_metadata(context):
104 git_revision = compute_git_revision(context.top_node)
105 full_version = context.pkg.version
David Cournapeau7f302cc2011-11-21 06:03:44106 if not _SETUP_PY.ISRELEASED:
107 full_version += '.dev-' + git_revision[:7]
David Cournapeau7f302cc2011-11-21 06:03:44108
David Cournapeau6fe584f2012-06-11 10:14:58109 context.register_metadata("git_revision", git_revision)
110 context.register_metadata("is_released", _SETUP_PY.ISRELEASED)
111 context.register_metadata("full_version", full_version)
David Cournapeau7f302cc2011-11-21 06:03:44112
David Cournapeau87295b32012-05-31 09:25:20113@hooks.post_configure
114def post_configure(context):
David Cournapeau3cb783e2012-04-16 18:31:44115 conf = context.waf_context
David Cournapeau3cb783e2012-04-16 18:31:44116 if conf.env["CC_NAME"] == "gcc":
117 conf.env.CFLAGS_PYEXT.append("-Wfatal-errors")
118 check_blas_lapack(conf)
119
David Cournapeau0d8b6362011-06-14 23:40:26120@hooks.pre_build
David Cournapeaua52f88f2011-04-06 00:18:04121def pre_build(context):
David Cournapeau6fe584f2012-06-11 10:14:58122 _register_metadata(context)
David Cournapeau7f302cc2011-11-21 06:03:44123
David Cournapeau6fe584f2012-06-11 10:14:58124@hooks.pre_sdist
125def pre_sdist(context):
126 _register_metadata(context)