當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。