""" 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 # 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 from bento.utils.utils \ import \ cmd_is_runnable 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 except waflib.Errors.ConfigurationError: conf.env.HAS_LAPACK = False try: conf.check_cc(lib=mkl_libs, msg="Checking for MKL (LAPACK)", uselib_store="LAPACK") conf.env.HAS_LAPACK = True except waflib.Errors.ConfigurationError: conf.env.HAS_LAPACK = False elif sys.platform == "darwin": try: conf.check(framework="Accelerate", msg="Checking for framework Accelerate (CBLAS)", uselib_store="CBLAS") conf.env.HAS_CBLAS = True except waflib.Errors.ConfigurationError: conf.env.HAS_CBLAS = False try: conf.check(framework="Accelerate", msg="Checking for framework Accelerate (LAPACK)", uselib_store="LAPACK") conf.env.HAS_LAPACK = True except waflib.Errors.ConfigurationError: conf.env.HAS_LAPACK = False else: try: conf.check_cc(lib=["cblas", "atlas"], uselib_store="CBLAS") conf.env.HAS_CBLAS = True except waflib.Errors.ConfigurationError: conf.env.HAS_CBLAS = False try: conf.check_cc(lib=["lapack", "f77blas", "cblas", "atlas"], uselib_store="LAPACK") conf.env.HAS_LAPACK = True except waflib.Errors.ConfigurationError: conf.env.HAS_LAPACK = False # 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 compute_git_revision(top_node): git_repo_node = top_node.find_node(".git") if git_repo_node and cmd_is_runnable(["git", "--version"]): s = subprocess.Popen(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=top_node.abspath()) out = s.communicate()[0] return out.decode().strip() else: return "" def _register_metadata(context): git_revision = compute_git_revision(context.top_node) full_version = context.pkg.version if not _SETUP_PY.ISRELEASED: full_version += '.dev-' + git_revision[:7] context.register_metadata("git_revision", git_revision) context.register_metadata("is_released", _SETUP_PY.ISRELEASED) context.register_metadata("full_version", full_version) @hooks.post_configure def post_configure(context): conf = context.waf_context if conf.env["CC_NAME"] == "gcc": conf.env.CFLAGS_PYEXT.append("-Wfatal-errors") check_blas_lapack(conf) @hooks.pre_build def pre_build(context): _register_metadata(context) @hooks.pre_sdist def pre_sdist(context): _register_metadata(context)