提交 7c8e8312 authored 作者: Frederic's avatar Frederic

Raise a new exception MissingGXX when trying to compile c code when we don't have a compiler.

上级 ecffc8a9
...@@ -83,6 +83,14 @@ METH_VARARGS = "METH_VARARGS" ...@@ -83,6 +83,14 @@ METH_VARARGS = "METH_VARARGS"
METH_NOARGS = "METH_NOARGS" METH_NOARGS = "METH_NOARGS"
class MissingGXX(Exception):
"""
This error is raised when we try to generate c code,
but g++ is not available
"""
pass
def debug_counter(name, every=1): def debug_counter(name, every=1):
"""Debug counter to know how often we go through some piece of code. """Debug counter to know how often we go through some piece of code.
...@@ -1473,6 +1481,9 @@ class GCC_compiler(object): ...@@ -1473,6 +1481,9 @@ class GCC_compiler(object):
:returns: dynamically-imported python module of the compiled code. :returns: dynamically-imported python module of the compiled code.
""" """
#TODO: Do not do the dlimport in this function #TODO: Do not do the dlimport in this function
if not theano.config.cxx:
raise MissingGXX("g++ not available! We can't compile c code.")
if include_dirs is None: if include_dirs is None:
include_dirs = [] include_dirs = []
......
...@@ -492,7 +492,7 @@ try: ...@@ -492,7 +492,7 @@ try:
# skip VM.__init__ # skip VM.__init__
except ImportError: except ImportError:
pass pass
except OSError: except (OSError, theano.gof.cmodule.MissingGXX):
# OSError happens when g++ is not installed. In that case, we # OSError happens when g++ is not installed. In that case, we
# already changed the default linker to something else then CVM. # already changed the default linker to something else then CVM.
# Currently this is the py linker. # Currently this is the py linker.
......
...@@ -571,7 +571,7 @@ class Scan(PureOp): ...@@ -571,7 +571,7 @@ class Scan(PureOp):
args, args,
outs, outs,
self) self)
except ImportError: except (ImportError, theano.gof.cmodule.MissingGXX):
p = self.execute p = self.execute
# default arguments are stored in the closure of `rval` # default arguments are stored in the closure of `rval`
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论