提交 ea17e455 authored 作者: Frederic's avatar Frederic

Don't try to compile scan cython code if no compiler. More robust if the c file isn't available.

上级 bb085872
...@@ -89,11 +89,11 @@ except ImportError: ...@@ -89,11 +89,11 @@ except ImportError:
if not os.path.exists(cfile): if not os.path.exists(cfile):
# This can happen in not normal case. We just # This can happen in not normal case. We just
# disable the c clinker. If we are here the user # disable the c clinker. If we are here the user
# didn't disable the compiler, so print a warning. # didn't disabled the compiler, so print a warning.
warnings.warn( warnings.warn(
"The file lazylinker_c.c is not available. This do" "The file lazylinker_c.c is not available. This do"
"not happen normally. You are probably in a strange" "not happen normally. You are probably in a strange"
"setup. This mean Theano ca not use the cvm:" "setup. This mean Theano can not use the cvm:"
"our c execution engine for Theano function. If you" "our c execution engine for Theano function. If you"
"want to remove this warning, use the Theano flag" "want to remove this warning, use the Theano flag"
"'cxx=' (set to an empty string) to disable all c" "'cxx=' (set to an empty string) to disable all c"
......
...@@ -54,11 +54,27 @@ except ImportError: ...@@ -54,11 +54,27 @@ except ImportError:
if version != getattr(scan_perform, '_version', None): if version != getattr(scan_perform, '_version', None):
raise ImportError() raise ImportError()
except ImportError: except ImportError:
if not theano.config.cxx:
raise ImportError("no c compiler, can't compile cython code")
_logger.info("Compiling C code for scan") _logger.info("Compiling C code for scan")
dirname = 'scan_perform' dirname = 'scan_perform'
cfile = os.path.join(theano.__path__[0], 'scan_module', cfile = os.path.join(theano.__path__[0], 'scan_module',
'scan_perform.c') 'scan_perform.c')
if not os.path.exists(cfile):
# This can happen in not normal case. We just
# disable the cython code. If we are here the user
# didn't disabled the compiler, so print a warning.
warnings.warn(
"The file scan_perform.c is not available. This do"
"not happen normally. You are probably in a strange"
"setup. This mean Theano can not use the cython code for "
"scan. If you"
"want to remove this warning, use the Theano flag"
"'cxx=' (set to an empty string) to disable all c"
"code generation."
)
raise ImportError("The file lazylinker_c.c is not available.")
code = open(cfile).read() code = open(cfile).read()
loc = os.path.join(config.compiledir, dirname) loc = os.path.join(config.compiledir, dirname)
if not os.path.exists(loc): if not os.path.exists(loc):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论