當前位置: 首頁>>代碼示例>>Python>>正文


Python Build.cythonize方法代碼示例

本文整理匯總了Python中Cython.Build.cythonize方法的典型用法代碼示例。如果您正苦於以下問題:Python Build.cythonize方法的具體用法?Python Build.cythonize怎麽用?Python Build.cythonize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Cython.Build的用法示例。


在下文中一共展示了Build.cythonize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_ext_modules

# 需要導入模塊: from Cython import Build [as 別名]
# 或者: from Cython.Build import cythonize [as 別名]
def get_ext_modules():
    ext = '.pyx' if HAVE_CYTHON else '.c'
    src_files = glob.glob(os.path.join(
        os.path.dirname(__file__),
        "pairtools", "*" + ext))

    ext_modules = []
    for src_file in src_files:
        name = "pairtools." + os.path.splitext(os.path.basename(src_file))[0]
        ext_modules.append(Extension(name, [src_file]))

    if HAVE_CYTHON:
        # .pyx to .c
        ext_modules = cythonize(ext_modules)  #, annotate=True

    return ext_modules 
開發者ID:mirnylab,項目名稱:pairtools,代碼行數:18,代碼來源:setup.py

示例2: compat_extension

# 需要導入模塊: from Cython import Build [as 別名]
# 或者: from Cython.Build import cythonize [as 別名]
def compat_extension():
    info('setting up compat extension')

    extra_compile_args = list(base_compile_args)

    if have_cython:
        sources = ['numcodecs/compat_ext.pyx']
    else:
        sources = ['numcodecs/compat_ext.c']

    # define extension module
    extensions = [
        Extension('numcodecs.compat_ext',
                  sources=sources,
                  extra_compile_args=extra_compile_args),
    ]

    if have_cython:
        extensions = cythonize(extensions)

    return extensions 
開發者ID:zarr-developers,項目名稱:numcodecs,代碼行數:23,代碼來源:setup.py

示例3: maybe_cythonize_extensions

# 需要導入模塊: from Cython import Build [as 別名]
# 或者: from Cython.Build import cythonize [as 別名]
def maybe_cythonize_extensions(top_path, config):
    """Tweaks for building extensions between release and development mode."""
    is_release = os.path.exists(os.path.join(top_path, 'PKG-INFO'))
    if is_release:
        build_from_c_and_cpp_files(config.ext_modules)
    else:
        message = ('Please install cython with a version >= {0} in order '
                   'to build a scikit-multiflow development version.').format(
                       CYTHON_MIN_VERSION)
        try:
            import Cython
            if LooseVersion(Cython.__version__) < CYTHON_MIN_VERSION:
                message += ' Your version of Cython was {0}.'.format(
                    Cython.__version__)
                raise ValueError(message)
            from Cython.Build import cythonize
        except ImportError as exc:
            exc.args += (message,)
            raise
        config.ext_modules = cythonize(config.ext_modules,
                                       compiler_directives={'language_level': 3}) 
開發者ID:scikit-multiflow,項目名稱:scikit-multiflow,代碼行數:23,代碼來源:setup.py

示例4: run

# 需要導入模塊: from Cython import Build [as 別名]
# 或者: from Cython.Build import cythonize [as 別名]
def run(self):
        # add numpy headers
        import numpy
        self.include_dirs.append(numpy.get_include())

        # add dimod headers
        include = os.path.join(os.path.dirname(__file__), 'dimod', 'include')
        self.include_dirs.append(include)

        if self.build_tests:

            test_extensions = [Extension('*', ['tests/test_*'+ext])]
            if USE_CYTHON:
                test_extensions = cythonize(test_extensions,
                                            # annotate=True
                                            )
            self.extensions.extend(test_extensions)

        super().run() 
開發者ID:dwavesystems,項目名稱:dimod,代碼行數:21,代碼來源:setup.py

示例5: ext_modules

# 需要導入模塊: from Cython import Build [as 別名]
# 或者: from Cython.Build import cythonize [as 別名]
def ext_modules(self):
        if SOURCE_EXT != 'pyx':
            return getattr(self, '_ext_modules', None)

        if getattr(self, '_ext_modules', None) is None:
            return None

        if getattr(self, '_last_run_command', None) in DONT_CYTHONIZE_FOR:
            return self._ext_modules

        if getattr(self, '_cythonized_ext_modules', None) is None:
            self._cythonized_ext_modules = cythonize(
                self._ext_modules,
                language_level=2,
            )

        return self._cythonized_ext_modules 
開發者ID:pythongssapi,項目名稱:python-gssapi,代碼行數:19,代碼來源:setup.py

示例6: configuration

# 需要導入模塊: from Cython import Build [as 別名]
# 或者: from Cython.Build import cythonize [as 別名]
def configuration(parent_package='', top_path=None):
    if os.path.exists('MANIFEST'):
        os.remove('MANIFEST')

    from numpy.distutils.misc_util import Configuration
    config = Configuration(None, parent_package, top_path)

    config.set_options(ignore_setup_xxx_py=True,
                       assume_default_configuration=True,
                       delegate_options_to_subpackages=True,
                       quiet=True)

    config.add_subpackage('modl')

    config.ext_modules = cythonize(config.ext_modules, nthreads=4)

    return config 
開發者ID:arthurmensch,項目名稱:modl,代碼行數:19,代碼來源:setup.py

示例7: run

# 需要導入模塊: from Cython import Build [as 別名]
# 或者: from Cython.Build import cythonize [as 別名]
def run(self):
        from Cython.Build import cythonize

        self.generate_pyx()

        cythonize(
            [
                Extension(
                    "lightfm._lightfm_fast_no_openmp",
                    ["lightfm/_lightfm_fast_no_openmp.pyx"],
                ),
                Extension(
                    "lightfm._lightfm_fast_openmp",
                    ["lightfm/_lightfm_fast_openmp.pyx"],
                    extra_link_args=["-fopenmp"],
                ),
            ]
        ) 
開發者ID:lyst,項目名稱:lightfm,代碼行數:20,代碼來源:setup.py

示例8: setup_package

# 需要導入模塊: from Cython import Build [as 別名]
# 或者: from Cython.Build import cythonize [as 別名]
def setup_package():

    metadata = dict(name=spfeas_name,
                    maintainer=maintainer,
                    maintainer_email=maintainer_email,
                    description=description,
                    license=license_file,
                    version=__version__,
                    long_description=long_description,
                    author=author_file,
                    packages=get_packages(),
                    package_data=get_package_data(),
                    ext_modules=cythonize(get_pyx_list()),
                    include_dirs=[np.get_include()],
                    cmdclass=dict(build_ext=build_ext),
                    zip_safe=False,
                    download_url=git_url,
                    install_requires=required_packages,
                    entry_points=get_console_dict())

    setup(**metadata) 
開發者ID:jgrss,項目名稱:spfeas,代碼行數:23,代碼來源:setup.py

示例9: maybe_cythonize_extensions

# 需要導入模塊: from Cython import Build [as 別名]
# 或者: from Cython.Build import cythonize [as 別名]
def maybe_cythonize_extensions(top_path, config):
    """Tweaks for building extensions between release and development mode."""
    is_release = os.path.exists(os.path.join(top_path, 'PKG-INFO'))

    if is_release:
        build_from_c_and_cpp_files(config.ext_modules)
    else:
        message = ('Please install cython with a version >= {0} in order '
                   'to build a scikit-learn development version.').format(
                       CYTHON_MIN_VERSION)
        try:
            import Cython
            if LooseVersion(Cython.__version__) < CYTHON_MIN_VERSION:
                message += ' Your version of Cython was {0}.'.format(
                    Cython.__version__)
                raise ValueError(message)
            from Cython.Build import cythonize
        except ImportError as exc:
            exc.args += (message,)
            raise

        config.ext_modules = cythonize(config.ext_modules) 
開發者ID:nccgroup,項目名稱:Splunking-Crime,代碼行數:24,代碼來源:__init__.py

示例10: run

# 需要導入模塊: from Cython import Build [as 別名]
# 或者: from Cython.Build import cythonize [as 別名]
def run(self):

        from Cython.Build import cythonize

        if USE_ASAN:
            from Cython.Compiler import Options
            # make asan/valgrind's memory leak results better
            Options.generate_cleanup_code = True

        compiler_directives = {'language_level': 3, 'embedsignature': True}
        if linetrace:
            compiler_directives['linetrace'] = True

        self.extensions = cythonize(self.extensions, compiler_directives=compiler_directives)

        _build_ext.run(self)

        run_setup(os.path.join(os.getcwd(), "setup.py"),
                  ['build_py'] + extra_args) 
開發者ID:piqueserver,項目名稱:piqueserver,代碼行數:21,代碼來源:setup.py

示例11: get_extensions

# 需要導入模塊: from Cython import Build [as 別名]
# 或者: from Cython.Build import cythonize [as 別名]
def get_extensions():
    filenames = [os.path.splitext(f)[0] for f in os.listdir("src/urh/cythonext") if f.endswith(".pyx")]
    extensions = [Extension("urh.cythonext." + f, ["src/urh/cythonext/" + f + ".pyx"],
                            extra_compile_args=[OPEN_MP_FLAG],
                            extra_link_args=[OPEN_MP_FLAG],
                            language="c++") for f in filenames]

    ExtensionHelper.USE_RELATIVE_PATHS = True
    device_extensions, device_extras = ExtensionHelper.get_device_extensions_and_extras()
    extensions += device_extensions

    if NO_NUMPY_WARNINGS_FLAG:
        for extension in extensions:
            extension.extra_compile_args.append(NO_NUMPY_WARNINGS_FLAG)

    extensions = cythonize(extensions, compiler_directives=COMPILER_DIRECTIVES, compile_time_env=device_extras)
    return extensions 
開發者ID:jopohl,項目名稱:urh,代碼行數:19,代碼來源:setup.py

示例12: config_cython

# 需要導入模塊: from Cython import Build [as 別名]
# 或者: from Cython.Build import cythonize [as 別名]
def config_cython():
    """Try to configure cython and return cython configuration"""
    if not with_cython:
        return []
    # pylint: disable=unreachable
    if os.name == 'nt':
        print("WARNING: Cython is not supported on Windows, will compile without cython module")
        return []

    try:
        from Cython.Build import cythonize
        # from setuptools.extension import Extension
        if sys.version_info >= (3, 0):
            subdir = "_cy3"
        else:
            subdir = "_cy2"
        ret = []
        path = "mxnet/cython"
        if os.name == 'nt':
            library_dirs = ['mxnet', '../build/Release', '../build']
            libraries = ['libmxnet']
        else:
            library_dirs = None
            libraries = None

        for fn in os.listdir(path):
            if not fn.endswith(".pyx"):
                continue
            ret.append(Extension(
                "mxnet/%s/.%s" % (subdir, fn[:-4]),
                ["mxnet/cython/%s" % fn],
                include_dirs=["../include/", "../3rdparty/tvm/nnvm/include"],
                library_dirs=library_dirs,
                libraries=libraries,
                language="c++"))
        return cythonize(ret)
    except ImportError:
        print("WARNING: Cython is not installed, will compile without cython module")
        return [] 
開發者ID:awslabs,項目名稱:dynamic-training-with-apache-mxnet-on-aws,代碼行數:41,代碼來源:setup.py

示例13: configuration

# 需要導入模塊: from Cython import Build [as 別名]
# 或者: from Cython.Build import cythonize [as 別名]
def configuration(parent_package='', top_path=None):
    from numpy.distutils.misc_util import Configuration
    from numpy.distutils.system_info import get_info
    import numpy

    libraries = []
    if os.name == 'posix':
        libraries.append('m')

    config = Configuration('pulse2percept', parent_package, top_path)

    # submodules which do not have their own setup.py
    # we must manually add sub-submodules & tests
    config.add_subpackage('implants')
    config.add_subpackage('implants/tests')
    config.add_subpackage('utils')
    config.add_subpackage('utils/tests')
    config.add_subpackage('percepts')
    config.add_subpackage('percepts/tests')
    config.add_subpackage('viz')
    config.add_subpackage('viz/tests')
    config.add_subpackage('datasets')
    config.add_subpackage('datasets/tests')

    # Submodules which have their own setup.py; e.g., because they use Cython:
    config.add_subpackage('models')
    config.add_subpackage('stimuli')

    # Data directories
    config.add_data_dir('datasets/data')
    config.add_data_dir('stimuli/data')

    # https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#compiler-directives
    config.ext_modules = cythonize(config.ext_modules,
                                   compiler_directives={
                                       'language_level': 3,  # use Py3 runtime
                                       'boundscheck': False,  # no IndexError
                                       'wraparound': False,  # no arr[-1]
                                       'initializedcheck': False,  # no None
                                   })
    return config 
開發者ID:pulse2percept,項目名稱:pulse2percept,代碼行數:43,代碼來源:setup.py

示例14: setup_cython_extension

# 需要導入模塊: from Cython import Build [as 別名]
# 或者: from Cython.Build import cythonize [as 別名]
def setup_cython_extension():
    try:
        from Cython.Build import cythonize
    except:
        return []
    # see tenpy/tools/optimization.py for details on "TENPY_OPTIMIZE"
    TENPY_OPTIMIZE = int(os.getenv('TENPY_OPTIMIZE', 1))
    include_dirs = [numpy.get_include()]
    libs = []
    lib_dirs = []

    extensions = [
        Extension("*", ["tenpy/linalg/*.pyx"],
                  include_dirs=include_dirs,
                  libraries=libs,
                  library_dirs=lib_dirs,
                  language='c++')
    ]

    comp_direct = {  # compiler_directives
        'language_level': 3,  # use python 3
        'embedsignature': True,  # write function signature in doc-strings
    }
    if TENPY_OPTIMIZE > 1:
        comp_direct['initializedcheck'] = False
        comp_direct['boundscheck'] = False
    if TENPY_OPTIMIZE < 1:
        comp_direct['profile'] = True
        comp_direct['linetrace'] = True

    # compile time flags (#DEF ...)
    comp_flags = {'TENPY_OPTIMIZE': TENPY_OPTIMIZE}

    ext_modules = cythonize(extensions,
                            compiler_directives=comp_direct,
                            compile_time_env=comp_flags)
    return ext_modules 
開發者ID:tenpy,項目名稱:tenpy,代碼行數:39,代碼來源:setup.py

示例15: zstd_extension

# 需要導入模塊: from Cython import Build [as 別名]
# 或者: from Cython.Build import cythonize [as 別名]
def zstd_extension():
    info('setting up Zstandard extension')

    zstd_sources = []
    extra_compile_args = list(base_compile_args)
    include_dirs = []
    define_macros = []

    # setup sources - use zstd bundled in blosc
    zstd_sources += glob('c-blosc/internal-complibs/zstd*/common/*.c')
    zstd_sources += glob('c-blosc/internal-complibs/zstd*/compress/*.c')
    zstd_sources += glob('c-blosc/internal-complibs/zstd*/decompress/*.c')
    zstd_sources += glob('c-blosc/internal-complibs/zstd*/dictBuilder/*.c')
    include_dirs += [d for d in glob('c-blosc/internal-complibs/zstd*')
                     if os.path.isdir(d)]
    include_dirs += [d for d in glob('c-blosc/internal-complibs/zstd*/*')
                     if os.path.isdir(d)]
    # define_macros += [('CYTHON_TRACE', '1')]

    if have_cython:
        sources = ['numcodecs/zstd.pyx']
    else:
        sources = ['numcodecs/zstd.c']

    # define extension module
    extensions = [
        Extension('numcodecs.zstd',
                  sources=sources + zstd_sources,
                  include_dirs=include_dirs,
                  define_macros=define_macros,
                  extra_compile_args=extra_compile_args,
                  ),
    ]

    if have_cython:
        extensions = cythonize(extensions)

    return extensions 
開發者ID:zarr-developers,項目名稱:numcodecs,代碼行數:40,代碼來源:setup.py


注:本文中的Cython.Build.cythonize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。