提交 f2573508 authored 作者: Ray Donnelly's avatar Ray Donnelly

Conda: Un-special-case mkl/GCC-on-Windows detection

Since each of Anaconda/Miniconda/conda-forge change sys.version to contain different things, and some users may install MKL outside of conda, always try the import and then, if using conda, give some useful information on how to install MKL (by installing `mkl-service` not `mkl`).
上级 ab94990c
...@@ -430,7 +430,7 @@ if rc != 0: ...@@ -430,7 +430,7 @@ if rc != 0:
except OSError: except OSError:
rc = 1 rc = 1
if rc != 0: if rc != 0:
_logger.warning("conda g++ not available, use `conda install m2w64-toolchain`") _logger.warning("g++ not available, if using conda: `conda install m2w64-toolchain`")
if rc != 0: if rc != 0:
param = "" param = ""
...@@ -1251,40 +1251,38 @@ def default_blas_ldflags(): ...@@ -1251,40 +1251,38 @@ def default_blas_ldflags():
['-l%s' % l for l in ["mk2_core", "mk2_intel_thread", ['-l%s' % l for l in ["mk2_core", "mk2_intel_thread",
"mk2_rt"]]) "mk2_rt"]])
# Anaconda # MKL
if "Anaconda" in sys.version or "Continuum" in sys.version: # If mkl can be imported then use it. On conda:
# If the "mkl-service" conda package (available # "conda install mkl-service" installs the Python wrapper and
# through Python package "mkl") is installed and # the low-level C libraries as well as optimised version of
# importable, then the libraries (installed by conda # numpy and scipy.
# package "mkl-rt") are actually available. Using try:
# "conda install mkl" will install both, as well as import mkl # noqa
# optimized versions of numpy and scipy. except ImportError as e:
try: if any([m for m in ('conda', 'Continuum') if m in sys.version]):
import mkl # noqa _logger.warning('install mkl with `conda install mkl-service`: %s', e)
except ImportError as e: else:
_logger.info('Conda mkl is not available: %s', e) # This branch is executed if no exception was raised
if sys.platform == "win32":
lib_path = [os.path.join(sys.prefix, 'Library', 'bin')]
flags = ['-L"%s"' % lib_path]
else: else:
# This branch is executed if no exception was raised lib_path = blas_info.get('library_dirs', [])
if sys.platform == "win32": flags = []
lib_path = os.path.join(sys.prefix, 'Library', 'bin') if lib_path:
flags = ['-L"%s"' % lib_path] flags = ['-L%s' % lib_path[0]]
else: flags += ['-l%s' % l for l in ["mkl_core",
lib_path = blas_info.get('library_dirs', []) "mkl_intel_thread",
flags = [] "mkl_rt"]]
if lib_path: res = try_blas_flag(flags)
flags = ['-L%s' % lib_path[0]] if res:
flags += ['-l%s' % l for l in ["mkl_core", return res
"mkl_intel_thread", flags.extend(['-Wl,-rpath,' + l for l in
"mkl_rt"]] blas_info.get('library_dirs', [])])
res = try_blas_flag(flags) res = try_blas_flag(flags)
if res: if res:
return res maybe_add_to_os_environ_pathlist('PATH', lib_path[0])
flags.extend(['-Wl,-rpath,' + l for l in return res
blas_info.get('library_dirs', [])])
res = try_blas_flag(flags)
if res:
maybe_add_to_os_environ_pathlist('PATH', lib_path)
return res
# to support path that includes spaces, we need to wrap it with double quotes on Windows # to support path that includes spaces, we need to wrap it with double quotes on Windows
path_wrapper = "\"" if os.name == 'nt' else "" path_wrapper = "\"" if os.name == 'nt' else ""
...@@ -1313,13 +1311,10 @@ def default_blas_ldflags(): ...@@ -1313,13 +1311,10 @@ def default_blas_ldflags():
if res: if res:
return res return res
# Try to add the anaconda lib directory to runtime loading of lib. # Add sys.prefix/lib to the runtime search path. On
# This fix some case with Anaconda 2.3 on Linux. # non-system installations of Python that use the
# Newer Anaconda still have this problem but only have # system linker, this is generally neccesary.
# Continuum in sys.version. if sys.platform in ("linux", "darwin"):
if (("Anaconda" in sys.version or
"Continuum" in sys.version) and
"linux" in sys.platform):
lib_path = os.path.join(sys.prefix, 'lib') lib_path = os.path.join(sys.prefix, 'lib')
ret.append('-Wl,-rpath,' + lib_path) ret.append('-Wl,-rpath,' + lib_path)
res = try_blas_flag(ret) res = try_blas_flag(ret)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论