提交 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,22 +1251,20 @@ def default_blas_ldflags(): ...@@ -1251,22 +1251,20 @@ 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
# "conda install mkl" will install both, as well as
# optimized versions of numpy and scipy.
try: try:
import mkl # noqa import mkl # noqa
except ImportError as e: except ImportError as e:
_logger.info('Conda mkl is not available: %s', e) if any([m for m in ('conda', 'Continuum') if m in sys.version]):
_logger.warning('install mkl with `conda install mkl-service`: %s', e)
else: else:
# This branch is executed if no exception was raised # This branch is executed if no exception was raised
if sys.platform == "win32": if sys.platform == "win32":
lib_path = os.path.join(sys.prefix, 'Library', 'bin') lib_path = [os.path.join(sys.prefix, 'Library', 'bin')]
flags = ['-L"%s"' % lib_path] flags = ['-L"%s"' % lib_path]
else: else:
lib_path = blas_info.get('library_dirs', []) lib_path = blas_info.get('library_dirs', [])
...@@ -1283,7 +1281,7 @@ def default_blas_ldflags(): ...@@ -1283,7 +1281,7 @@ def default_blas_ldflags():
blas_info.get('library_dirs', [])]) blas_info.get('library_dirs', [])])
res = try_blas_flag(flags) res = try_blas_flag(flags)
if res: if res:
maybe_add_to_os_environ_pathlist('PATH', lib_path) maybe_add_to_os_environ_pathlist('PATH', lib_path[0])
return res 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
...@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论