当前位置: 首页>>代码示例>>Python>>正文


Python extension.Extension方法代码示例

本文整理汇总了Python中setuptools.extension.Extension方法的典型用法代码示例。如果您正苦于以下问题:Python extension.Extension方法的具体用法?Python extension.Extension怎么用?Python extension.Extension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在setuptools.extension的用法示例。


在下文中一共展示了extension.Extension方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_extension

# 需要导入模块: from setuptools import extension [as 别名]
# 或者: from setuptools.extension import Extension [as 别名]
def make_extension(name_fmt, module, **kwargs):
    """Helper method to remove the repetition in extension declarations."""
    source = name_fmt.replace('.', '/') % module + '.' + SOURCE_EXT
    if not os.path.exists(source):
        raise OSError(source)
    return Extension(
        name_fmt % module,
        extra_link_args=link_args,
        extra_compile_args=compile_args,
        library_dirs=library_dirs,
        libraries=libraries,
        sources=[source],
        **kwargs
    )


# detect support 
开发者ID:pythongssapi,项目名称:python-gssapi,代码行数:19,代码来源:setup.py

示例2: get_ext_modules

# 需要导入模块: from setuptools import extension [as 别名]
# 或者: from setuptools.extension import Extension [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

示例3: test_abi3_filename

# 需要导入模块: from setuptools import extension [as 别名]
# 或者: from setuptools.extension import Extension [as 别名]
def test_abi3_filename(self):
        """
        Filename needs to be loadable by several versions
        of Python 3 if 'is_abi3' is truthy on Extension()
        """
        print(get_abi3_suffix())

        extension = Extension('spam.eggs', ['eggs.c'], py_limited_api=True)
        dist = Distribution(dict(ext_modules=[extension]))
        cmd = build_ext(dist)
        cmd.finalize_options()
        assert 'spam.eggs' in cmd.ext_map
        res = cmd.get_ext_filename('spam.eggs')

        if six.PY2 or not get_abi3_suffix():
            assert res.endswith(get_config_var('EXT_SUFFIX'))
        elif sys.platform == 'win32':
            assert res.endswith('eggs.pyd')
        else:
            assert 'abi3' in res 
开发者ID:pypa,项目名称:setuptools,代码行数:22,代码来源:test_build_ext.py

示例4: config_cython

# 需要导入模块: from setuptools import extension [as 别名]
# 或者: from setuptools.extension import Extension [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

示例5: extensions

# 需要导入模块: from setuptools import extension [as 别名]
# 或者: from setuptools.extension import Extension [as 别名]
def extensions():
    from Cython.Build import cythonize
    import numpy
    extensions = [Extension('utils',
                  ['nagisa/utils.pyx'],
                  include_dirs = [numpy.get_include()])]
    return cythonize(extensions) 
开发者ID:taishi-i,项目名称:nagisa,代码行数:9,代码来源:setup.py

示例6: make_extension

# 需要导入模块: from setuptools import extension [as 别名]
# 或者: from setuptools.extension import Extension [as 别名]
def make_extension():
    global _CYTHON_COMPILE_TIME_ENV
    build_args = get_build_args()
    _CYTHON_COMPILE_TIME_ENV = build_args.pop('cython_compile_time_env')
    return Extension("tesserocr", sources=["tesserocr.pyx"], language="c++", **build_args) 
开发者ID:sirfz,项目名称:tesserocr,代码行数:7,代码来源:setup.py

示例7: _ext_modules

# 需要导入模块: from setuptools import extension [as 别名]
# 或者: from setuptools.extension import Extension [as 别名]
def _ext_modules(self, poet):
        """
        Builds the extension modules.
        
        Transforms the extensions section:
        
        [extensions]
        "my.module" = "my/module.c"
        
        to a proper extension:
        
        Extension('my.module', 'my/module.c')
        
        :param poet: The Poet instance for which to build.
        :type poet: poet.poet.Poet
        
        :rtype: dict 
        """
        extensions = []
        for module, source in poet.extensions.items():
            if not isinstance(source, list):
                source = [source]

            extensions.append(Extension(module, source))

        return {
            'ext_modules': extensions
        } 
开发者ID:sdispater,项目名称:poet,代码行数:30,代码来源:builder.py

示例8: findpackages

# 需要导入模块: from setuptools import extension [as 别名]
# 或者: from setuptools.extension import Extension [as 别名]
def findpackages(dir_, files=[]):
    for file in os.listdir(dir_):
        if file != "build":
            path = os.path.join(dir_, file)
            if os.path.isdir(path):  # and path.endswith(".py"):
                for file1 in os.listdir(path):
                    if file1 == "__init__.py":
                        files.append(path.replace(os.path.sep, ".")[2:])
                findpackages(path, files)
    return files


# generate an Extension object from its dotted name 
开发者ID:cihologramas,项目名称:pyoptools,代码行数:15,代码来源:setup.py

示例9: makeExtension

# 需要导入模块: from setuptools import extension [as 别名]
# 或者: from setuptools.extension import Extension [as 别名]
def makeExtension(extName):
    extPath = extName.replace(".", os.path.sep)+".pyx"
    return Extension(
        extName,
        [extPath],
        # adding the '.' to include_dirs is CRUCIAL!!
        include_dirs=[".", include_numpy_array],
        extra_compile_args=["-O3", "-Wall"],
        # extra_link_args = ['-g'],
        # libraries = ["dv",],
        )


# Check the availability of arrayobject.h 
开发者ID:cihologramas,项目名称:pyoptools,代码行数:16,代码来源:setup.py

示例10: build_extension

# 需要导入模块: from setuptools import extension [as 别名]
# 或者: from setuptools.extension import Extension [as 别名]
def build_extension(extension_name, sources):
    full_path_sources = [SRC_PATH + src for src in sources]
    return Extension(name=extension_name, language='c++',
                     sources=full_path_sources,
                     extra_compile_args=['--std=c++11', '-Ofast', '-fomit-frame-pointer', "-g0"] + ouff_mac,
                     undef_macros=["NDEBUG"],
                     extra_link_args=ouff_mac) 
开发者ID:GeoDaCenter,项目名称:spatial_access,代码行数:9,代码来源:setup.py

示例11: make_extention

# 需要导入模块: from setuptools import extension [as 别名]
# 或者: from setuptools.extension import Extension [as 别名]
def make_extention(module_name, files, extra_compile_args, main_include_dir=os.path.join(os.getcwd(), 'include')):
    include_dirs = list(filter(
        lambda f: bool(f) and os.path.exists(f) and os.path.isdir(f),
        [os.path.join(module_name.split('.')[0], 'include'), main_include_dir]
    ))

    return Extension(
        module_name, files,
        extra_compile_args=extra_compile_args,
        include_dirs=include_dirs
    ) 
开发者ID:vstconsulting,项目名称:polemarch,代码行数:13,代码来源:setup.py

示例12: make_setup

# 需要导入模块: from setuptools import extension [as 别名]
# 或者: from setuptools.extension import Extension [as 别名]
def make_setup(**opts):
    if 'packages' not in opts:
        opts['packages'] = find_packages()
    ext_modules_list = opts.pop('ext_modules_list', list())
    ext_mod, ext_mod_dict = make_extensions(ext_modules_list, opts['packages'])
    opts['ext_modules'] = opts.get('ext_modules', list()) + ext_mod
    cmdclass = opts.get('cmdclass', dict())
    static_exclude = opts.pop('static_exclude_min', list())
    if 'compile' not in cmdclass:
        compile_class = get_compile_command(ext_mod_dict)
        compile_class.static_exclude = static_exclude
        cmdclass.update({"compile": get_compile_command(ext_mod_dict)})
    if has_cython:
        build_py.exclude = ext_modules_list
        install_lib.static_exclude = static_exclude
        install_lib.compile_exclude = opts.pop('compile_modules_exclude', list())
        cmdclass.update({
            'build_ext': _build_ext,
            'build_py': build_py,
            'install_lib': install_lib
        })
    if has_sphinx and 'build_sphinx' not in cmdclass:
        cmdclass['build_sphinx'] = BuildDoc
    cmdclass['githubrelease'] = GithubRelease
    opts['cmdclass'] = cmdclass

    webpack_path = os.path.join(os.getcwd(), 'webpack.config.js')
    if os.path.exists(webpack_path) and is_build and os.environ.get('DONT_YARN', "") != 'true':
        yarn_build_command = 'devBuild' if is_develop else 'build'
        try:
            os.system('yarn install --pure-lockfile')
            os.system('yarn ' + yarn_build_command)
        except Extension as err:
            print(err)

    setup(**opts)

########################################################################################
# end block 
开发者ID:vstconsulting,项目名称:polemarch,代码行数:41,代码来源:setup.py

示例13: config_cython

# 需要导入模块: from setuptools import extension [as 别名]
# 或者: from setuptools.extension import Extension [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/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:mahyarnajibi,项目名称:SNIPER-mxnet,代码行数:41,代码来源:setup.py

示例14: declare_cython_extension

# 需要导入模块: from setuptools import extension [as 别名]
# 或者: from setuptools.extension import Extension [as 别名]
def declare_cython_extension(extName, use_math=False, use_openmp=False):
    """Declare a Cython extension module for setuptools.

Parameters:
    extName : str
        Absolute module name, e.g. use `mylibrary.mypackage.subpackage`
        for the Cython source file `mylibrary/mypackage/subpackage.pyx`.

    use_math : bool
        If True, set math flags and link with ``libm``.

    use_openmp : bool
        If True, compile and link with OpenMP.

Return value:
    Extension object
        that can be passed to ``setuptools.setup``.
"""
    extPath = extName.replace(".", os.path.sep)+".pyx"

    if use_math:
        compile_args = list(my_extra_compile_args_math) # copy
        link_args    = list(my_extra_link_args_math)
        libraries    = ["m"]  # link libm; this is a list of library names without the "lib" prefix
    else:
        compile_args = list(my_extra_compile_args_nonmath)
        link_args    = list(my_extra_link_args_nonmath)
        libraries    = None  # value if no libraries, see setuptools.extension._Extension

    # OpenMP
    if use_openmp:
        compile_args.insert( 0, openmp_compile_args )
        link_args.insert( 0, openmp_link_args )

    # See
    #    http://docs.cython.org/src/tutorial/external.html
    #
    # on linking libraries to your Cython extensions.
    #
    return Extension( extName,
                      [extPath],
                      extra_compile_args=compile_args,
                      extra_link_args=link_args,
                      libraries=libraries
                    )


#########################################################
# Set up modules
#########################################################

# declare Cython extension modules here
# 
开发者ID:Technologicat,项目名称:setup-template-cython,代码行数:55,代码来源:setup.py

示例15: declare_cython_extension

# 需要导入模块: from setuptools import extension [as 别名]
# 或者: from setuptools.extension import Extension [as 别名]
def declare_cython_extension(extName, use_math=False, use_openmp=False, include_dirs=None):
    """Declare a Cython extension module for setuptools.

Parameters:
    extName : str
        Absolute module name, e.g. use `mylibrary.mypackage.mymodule`
        for the Cython source file `mylibrary/mypackage/mymodule.pyx`.

    use_math : bool
        If True, set math flags and link with ``libm``.

    use_openmp : bool
        If True, compile and link with OpenMP.

Return value:
    Extension object
        that can be passed to ``setuptools.setup``.
"""
    extPath = extName.replace(".", os.path.sep)+".pyx"

    if use_math:
        compile_args = list(my_extra_compile_args_math) # copy
        link_args    = list(my_extra_link_args_math)
        libraries    = ["m"]  # link libm; this is a list of library names without the "lib" prefix
    else:
        compile_args = list(my_extra_compile_args_nonmath)
        link_args    = list(my_extra_link_args_nonmath)
        libraries    = None  # value if no libraries, see setuptools.extension._Extension

    # OpenMP
    if use_openmp:
        compile_args.insert( 0, openmp_compile_args )
        link_args.insert( 0, openmp_link_args )

    # See
    #    http://docs.cython.org/src/tutorial/external.html
    #
    # on linking libraries to your Cython extensions.
    #
    return Extension( extName,
                      [extPath],
                      extra_compile_args=compile_args,
                      extra_link_args=link_args,
                      include_dirs=include_dirs,
                      libraries=libraries
                    )


# Gather user-defined data files
#
# http://stackoverflow.com/questions/13628979/setuptools-how-to-make-package-contain-extra-data-folder-and-all-folders-inside
# 
开发者ID:Technologicat,项目名称:setup-template-cython,代码行数:54,代码来源:setup.py


注:本文中的setuptools.extension.Extension方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。