Ejemplo n.º 1
0
def test_compiler_error():
    with pytest.raises(
            CompileError), tempfile.TemporaryDirectory() as dir_name:
        GCC_compiler.compile_str("module_name", "blah", location=dir_name)
Ejemplo n.º 2
0
                    "our c execution engine for Aesara function. If you"
                    "want to remove this warning, use the Aesara 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()
            loc = os.path.join(config.compiledir, dirname)
            if not os.path.exists(loc):
                try:
                    os.mkdir(loc)
                except OSError as e:
                    assert e.errno == errno.EEXIST
                    assert os.path.exists(loc)

            args = GCC_compiler.compile_args()
            GCC_compiler.compile_str(dirname, code, location=loc, preargs=args)
            # Save version into the __init__.py file.
            init_py = os.path.join(loc, "__init__.py")
            with open(init_py, "w") as f:
                f.write(f"_version = {version}\n")
            # If we just compiled the module for the first time, then it was
            # imported at the same time: we need to make sure we do not
            # reload the now outdated __init__.pyc below.
            init_pyc = os.path.join(loc, "__init__.pyc")
            if os.path.isfile(init_pyc):
                os.remove(init_pyc)
            try_import()
            try_reload()
            from lazylinker_ext import lazylinker_ext as lazy_c

            assert lazylinker_ext._version == lazy_c.get_version()