提交 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:
except OSError:
rc = 1
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:
param = ""
......@@ -1251,22 +1251,20 @@ def default_blas_ldflags():
['-l%s' % l for l in ["mk2_core", "mk2_intel_thread",
"mk2_rt"]])
# Anaconda
if "Anaconda" in sys.version or "Continuum" in sys.version:
# If the "mkl-service" conda package (available
# through Python package "mkl") is installed and
# importable, then the libraries (installed by conda
# package "mkl-rt") are actually available. Using
# "conda install mkl" will install both, as well as
# optimized versions of numpy and scipy.
# MKL
# If mkl can be imported then use it. On conda:
# "conda install mkl-service" installs the Python wrapper and
# the low-level C libraries as well as optimised version of
# numpy and scipy.
try:
import mkl # noqa
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:
# This branch is executed if no exception was raised
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]
else:
lib_path = blas_info.get('library_dirs', [])
......@@ -1283,7 +1281,7 @@ def default_blas_ldflags():
blas_info.get('library_dirs', [])])
res = try_blas_flag(flags)
if res:
maybe_add_to_os_environ_pathlist('PATH', lib_path)
maybe_add_to_os_environ_pathlist('PATH', lib_path[0])
return res
# to support path that includes spaces, we need to wrap it with double quotes on Windows
......@@ -1313,13 +1311,10 @@ def default_blas_ldflags():
if res:
return res
# Try to add the anaconda lib directory to runtime loading of lib.
# This fix some case with Anaconda 2.3 on Linux.
# Newer Anaconda still have this problem but only have
# Continuum in sys.version.
if (("Anaconda" in sys.version or
"Continuum" in sys.version) and
"linux" in sys.platform):
# Add sys.prefix/lib to the runtime search path. On
# non-system installations of Python that use the
# system linker, this is generally neccesary.
if sys.platform in ("linux", "darwin"):
lib_path = os.path.join(sys.prefix, 'lib')
ret.append('-Wl,-rpath,' + lib_path)
res = try_blas_flag(ret)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论