コード例 #1
0
            code = open(cfile).read()
            loc = os.path.join(config.compiledir, dirname)
            if not os.path.exists(loc):
                os.mkdir(loc)
            preargs = ['-pthread', '-fwrapv', '-O2', '-fno-strict-aliasing']
            preargs += cmodule.GCC_compiler.compile_args()
            cmodule.GCC_compiler.compile_str(dirname,
                                             code,
                                             location=loc,
                                             preargs=preargs)
            # Save version into the __init__.py file.
            init_py = os.path.join(loc, '__init__.py')
            open(init_py, 'w').write('_version = %s\n' % version)
            # 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)
            import scan_perform
            reload(scan_perform)
            from scan_perform import scan_perform as scan_c
            assert (scan_perform._version == scan_c.get_version())
            _logger.info("New version %s", scan_perform._version)
    finally:
        # Release lock on compilation directory.
        release_lock()

from scan_perform.scan_perform import *
assert version == get_version()
コード例 #2
0
ファイル: scan_perform_ext.py プロジェクト: 12190143/Theano
                                             preargs=preargs,
                                             hide_symbols=False)
            # Save version into the __init__.py file.
            init_py = os.path.join(loc, '__init__.py')
            with open(init_py, 'w') as f:
                f.write('_version = %s\n' % version)
            # 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 scan_perform import scan_perform as scan_c
            assert (scan_perform._version ==
                    scan_c.get_version())
            _logger.info("New version %s", scan_perform._version)
    finally:
        # Release lock on compilation directory.
        release_lock()

# This is caused as cython use the old NumPy C-API but we use the new one.
# To fix it completly, we would need to modify Cython to use the new API.
with warnings.catch_warnings():
    warnings.filterwarnings("ignore",
                            message="numpy.ndarray size changed")
    from scan_perform.scan_perform import *
assert version == get_version()
コード例 #3
0
ファイル: scan_perform_ext.py プロジェクト: rsk2327/Theano
                    preargs.append("-D NPY_ALIGNED=NPY_ARRAY_ALIGNED")
                    preargs.append("-D NPY_WRITEABLE=NPY_ARRAY_WRITEABLE")
                    preargs.append("-D NPY_UPDATE_ALL=NPY_ARRAY_UPDATE_ALL")
                    preargs.append("-D NPY_C_CONTIGUOUS=NPY_ARRAY_C_CONTIGUOUS")
                    preargs.append("-D NPY_F_CONTIGUOUS=NPY_ARRAY_F_CONTIGUOUS")

            cmodule.GCC_compiler.compile_str(dirname, code, location=loc,
                                             preargs=preargs)
            # Save version into the __init__.py file.
            init_py = os.path.join(loc, '__init__.py')
            open(init_py, 'w').write('_version = %s\n' % version)
            # 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 scan_perform import scan_perform as scan_c
            assert (scan_perform._version ==
                    scan_c.get_version())
            _logger.info("New version %s", scan_perform._version)
    finally:
        # Release lock on compilation directory.
        release_lock()

from scan_perform.scan_perform import *
assert version == get_version()
コード例 #4
0
            cmodule.GCC_compiler.compile_str(dirname,
                                             code,
                                             location=loc,
                                             preargs=preargs,
                                             hide_symbols=False)
            # 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 scan_perform import scan_perform as scan_c

            assert scan_perform._version == scan_c.get_version()
            _logger.info(f"New version {scan_perform._version}")

# This is caused as cython use the old NumPy C-API but we use the new one.
# To fix it completely, we would need to modify Cython to use the new API.
with warnings.catch_warnings():
    warnings.filterwarnings("ignore", message="numpy.ndarray size changed")
    from scan_perform.scan_perform import get_version, perform  # noqa: F401
assert version == get_version()
コード例 #5
0
ファイル: scan_perform_ext.py プロジェクト: rahul003/Theano
                    preargs.append("-D NPY_ALIGNED=NPY_ARRAY_ALIGNED")
                    preargs.append("-D NPY_WRITEABLE=NPY_ARRAY_WRITEABLE")
                    preargs.append("-D NPY_UPDATE_ALL=NPY_ARRAY_UPDATE_ALL")
                    preargs.append("-D NPY_C_CONTIGUOUS=NPY_ARRAY_C_CONTIGUOUS")
                    preargs.append("-D NPY_F_CONTIGUOUS=NPY_ARRAY_F_CONTIGUOUS")

            cmodule.GCC_compiler.compile_str(dirname, code, location=loc, preargs=preargs)
            # Save version into the __init__.py file.
            init_py = os.path.join(loc, "__init__.py")
            open(init_py, "w").write("_version = %s\n" % version)
            # 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 scan_perform import scan_perform as scan_c

            assert scan_perform._version == scan_c.get_version()
            _logger.info("New version %s", scan_perform._version)
    finally:
        # Release lock on compilation directory.
        release_lock()

from scan_perform.scan_perform import *

assert version == get_version()