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


Python setuptools.Extension方法代码示例

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


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

示例1: extensions

# 需要导入模块: import setuptools [as 别名]
# 或者: from setuptools import Extension [as 别名]
def extensions(coverage=False):
    for dirpath, dirnames, filenames in os.walk("src"):
        for fn in filenames:
            root, ext = os.path.splitext(fn)
            if ext != ".pyx":
                continue
            mod = ".".join(dirpath.split(os.sep)[1:] + [root])
            extension = Extension(
                mod,
                [os.path.join(dirpath, fn)],
                library_dirs=os.environ.get("LIBRARY_PATH", "").split(":"),
                libraries=["mbedcrypto", "mbedtls", "mbedx509"],
                define_macros=[
                    ("CYTHON_TRACE", "1"),
                    ("CYTHON_TRACE_NOGIL", "1"),
                ]
                if coverage
                else [],
            )
            extension.cython_directives = {"language_level": "3str"}
            if coverage:
                extension.cython_directives["linetrace"] = True
            yield extension 
开发者ID:Synss,项目名称:python-mbedtls,代码行数:25,代码来源:setup.py

示例2: method_mod

# 需要导入模块: import setuptools [as 别名]
# 或者: from setuptools import Extension [as 别名]
def method_mod(name):
	code = import_module('accelerator.standard_methods.' + name).c_module_code
	fn = 'accelerator/standard_methods/_generated_' + name + '.c'
	if exists(fn):
		with open(fn, 'r') as fh:
			old_code = fh.read()
	else:
		old_code = None
	if code != old_code:
		with open(fn, 'w') as fh:
			fh.write(code)
	return Extension(
		'accelerator.standard_methods._' + name,
		sources=[fn],
		libraries=['z'],
		extra_compile_args=['-std=c99', '-O3'],
	) 
开发者ID:eBay,项目名称:accelerator,代码行数:19,代码来源:setup.py

示例3: test_abi3_filename

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

# 需要导入模块: import setuptools [as 别名]
# 或者: from setuptools import Extension [as 别名]
def _get_extension(extension, file_ext):
    kwargs = {
        "name": ".".join(extension),
        "sources": ["%s.%s" % ("/".join(extension), file_ext)],
        "language": "c++",
        "extra_compile_args": ["-ffast-math"],
    }
    if NUMPY_AVAILABLE:
        # most of the time it's fine if the include_dirs aren't there
        kwargs["include_dirs"] = [numpy.get_include()]
    else:
        color_red_bold = "\033[1;31m"
        color_reset = "\033[m"
        sys.stderr.write(
            "%sNumpy is not available so we cannot include the libraries\n"
            "It will result in compilation failures where the numpy headers "
            "are missing.\n%s" % (color_red_bold, color_reset),
        )
    return Extension(**kwargs) 
开发者ID:lyst,项目名称:rpforest,代码行数:21,代码来源:setup.py

示例5: get_import_prefix

# 需要导入模块: import setuptools [as 别名]
# 或者: from setuptools import Extension [as 别名]
def get_import_prefix(module_path, root):
        """
        Computes the proper name of a Nim module amid a given Python project.

        This method is needed because Nim Extensions do not automatically know
        where they are within a given Python namespace. This method is vital for
        recursing through an entire Python project to find every Nim Extension
        module and library while preserving the namespace containing each one.

        Args:
            module_path(Path): the module for which to determine its namespace.
            root(Path): the path to the Python project containing the Extension.

        Returns:
            A tuple of packages containing the given module.
        """
        root_path = root.resolve()
        full_path = module_path.resolve()

        assert full_path >= root_path, 'Extension path is not within root dir.'

        return full_path.parts[len(root_path.parts):] 
开发者ID:Pebaz,项目名称:nimporter,代码行数:24,代码来源:nimporter.py

示例6: test_build_all_extensions

# 需要导入模块: import setuptools [as 别名]
# 或者: from setuptools import Extension [as 别名]
def test_build_all_extensions():
    "Make sure all extensions within a project are compiled correctly."

    extension_names = {'proj2.lib1', 'proj2.performance'}
    extensions = Nimporter.build_nim_extensions(Path('tests/proj2'))
    assert len(extensions) == 2

    for ext in extensions:
        assert ext.name in extension_names
        assert isinstance(ext, Extension)

        includes = set(Path(i) for i in ext.include_dirs)

        for source in ext.sources:
            src = Path(source).absolute()
            assert src.suffix == '.c'
            # assert src.parent in includes 
开发者ID:Pebaz,项目名称:nimporter,代码行数:19,代码来源:test_distribution.py

示例7: create_utils_extentions

# 需要导入模块: import setuptools [as 别名]
# 或者: from setuptools import Extension [as 别名]
def create_utils_extentions():
    return [
        Extension(
            'fluxclient.toolpath._toolpath',
            sources=[
                "src/toolpath/gcode_parser.cpp",
                "src/toolpath/gcode_writer.cpp",
                "src/toolpath/fcode_v1_writer.cpp",
                "src/toolpath/py_processor.cpp",
                "src/toolpath/_toolpath.pyx"
            ],
            language="c++",
            extra_compile_args=get_default_extra_compile_args(),
            include_dirs=[numpy.get_include()]),
        Extension(
            'fluxclient.utils._utils',
            sources=[
                "src/utils/utils_module.cpp",
                "src/utils/utils.pyx"],
            language="c++",
            extra_compile_args=get_default_extra_compile_args())
    ] 
开发者ID:flux3dp,项目名称:fluxclient,代码行数:24,代码来源:setup_utils.py

示例8: get_device_extension

# 需要导入模块: import setuptools [as 别名]
# 或者: from setuptools import Extension [as 别名]
def get_device_extension(dev_name: str, libraries: list, library_dirs: list, include_dirs: list):
    try:
        language = DEVICES[dev_name]["language"]
    except KeyError:
        language = "c++"

    cur_dir = os.path.dirname(os.path.realpath(__file__))
    if USE_RELATIVE_PATHS:
        # We need relative paths on windows
        cpp_file_path = "src/urh/dev/native/lib/{0}.pyx".format(dev_name)
    else:
        cpp_file_path = os.path.join(cur_dir, "lib", "{0}.pyx".format(dev_name))

    return Extension("urh.dev.native.lib." + dev_name,
                     [cpp_file_path],
                     libraries=libraries, library_dirs=library_dirs,
                     include_dirs=include_dirs, language=language) 
开发者ID:jopohl,项目名称:urh,代码行数:19,代码来源:ExtensionHelper.py

示例9: get_extensions

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

示例10: __new__

# 需要导入模块: import setuptools [as 别名]
# 或者: from setuptools import Extension [as 别名]
def __new__(cls, name, sources, *args, **kwargs):
        include_dirs = kwargs.get('include_dirs', [])
        include_dirs += include_paths(cuda=True)
        kwargs['include_dirs'] = include_dirs
        library_dirs = kwargs.get('library_dirs', [])
        library_dirs += library_paths(cuda=True)
        kwargs['library_dirs'] = library_dirs
        libraries = kwargs.get('libraries', [])
        libraries.extend(COMMON_LINK_LIBRARIES + ['cudart', 'dragon'])
        kwargs['libraries'] = libraries
        define_macros = kwargs.get('define_marcos', [])
        define_macros.append(('USE_CUDA', None))
        define_macros.append(('DRAGON_API=' + DLLIMPORT_STR, None))
        kwargs['define_macros'] = define_macros
        kwargs['language'] = 'c++'
        return _Extension(name, sources, *args, **kwargs) 
开发者ID:seetaresearch,项目名称:dragon,代码行数:18,代码来源:cpp_extension.py

示例11: make_cython_ext

# 需要导入模块: import setuptools [as 别名]
# 或者: from setuptools import Extension [as 别名]
def make_cython_ext(name, module, sources):
    extra_compile_args = None
    if platform.system() != 'Windows':
        extra_compile_args = {
            'cxx': ['-Wno-unused-function', '-Wno-write-strings']
        }

    extension = Extension(
        '{}.{}'.format(module, name),
        [os.path.join(*module.split('.'), p) for p in sources],
        include_dirs=[np.get_include()],
        language='c++',
        extra_compile_args=extra_compile_args)
    extension, = cythonize(extension)
    return extension 
开发者ID:ming71,项目名称:mmdetection-annotated,代码行数:17,代码来源:setup.py

示例12: make_ext

# 需要导入模块: import setuptools [as 别名]
# 或者: from setuptools import Extension [as 别名]
def make_ext(pkg_name, relpath, srcs, libraries=[], library_dirs=default_lib_dir,
             include_dirs=default_include, extra_compile_flags=[],
             extra_link_flags=[], **kwargs):
    if '/' in relpath:
        relpath = os.path.join(*relpath.split('/'))
    if (os.path.isfile(os.path.join(pyscf_lib_dir, 'build', 'CMakeCache.txt')) and
        os.path.isfile(os.path.join(pyscf_lib_dir, *pkg_name.split('.')) + so_ext)):
        return None
    else:
        if sys.platform.startswith('darwin'):
            soname = pkg_name.split('.')[-1]
            extra_link_flags = extra_link_flags + ['-install_name', '@loader_path/'+soname+so_ext]
            runtime_library_dirs = []
        elif sys.platform.startswith('aix') or sys.platform.startswith('os400'):
            extra_compile_flags = extra_compile_flags + ['-fopenmp']
            extra_link_flags = extra_link_flags + ['-lblas', '-lgomp', '-Wl,-brtl']
            runtime_library_dirs = ['$ORIGIN', '.']
        else:
            extra_compile_flags = extra_compile_flags + ['-fopenmp']
            extra_link_flags = extra_link_flags + ['-fopenmp']
            runtime_library_dirs = ['$ORIGIN', '.']
        srcs = make_src(relpath, srcs)
        return Extension(pkg_name, srcs,
                         libraries = libraries,
                         library_dirs = library_dirs,
                         include_dirs = include_dirs + [os.path.join(pyscf_lib_dir,relpath)],
                         extra_compile_args = extra_compile_flags,
                         extra_link_args = extra_link_flags,
# Be careful with the ld flag "-Wl,-R$ORIGIN" in the shell.
# When numpy.distutils is imported, the default CCompiler of distutils will be
# overwritten. Compilation is executed in shell and $ORIGIN will be converted to ''
                         runtime_library_dirs = runtime_library_dirs,
                         **kwargs) 
开发者ID:pyscf,项目名称:pyscf,代码行数:35,代码来源:setup.py

示例13: ext_modules

# 需要导入模块: import setuptools [as 别名]
# 或者: from setuptools import Extension [as 别名]
def ext_modules():
    import numpy

    walks_ext = Extension('jwalk.walks', ['jwalk/src/walks.pyx'],
                          include_dirs=[numpy.get_include()])

    return [walks_ext] 
开发者ID:jwplayer,项目名称:jwalk,代码行数:9,代码来源:setup.py

示例14: customize_compiler_for_nvcc

# 需要导入模块: import setuptools [as 别名]
# 或者: from setuptools import Extension [as 别名]
def customize_compiler_for_nvcc(self):
    """inject deep into distutils to customize how the dispatch
    to cc/nvcc works.
    If you subclass UnixCCompiler, it's not trivial to get your subclass
    injected in, and still have the right customizations (i.e.
    distutils.sysconfig.customize_compiler) run on it. So instead of going
    the OO route, I have this. Note, it's kindof like a wierd functional
    subclassing going on."""

    # tell the compiler it can processes .cu
    self.src_extensions.append('.cu')

    # save references to the default compiler_so and _comple methods
    default_compiler_so = self.compiler_so
    super = self._compile

    # now redefine the _compile method. This gets executed for each
    # object but distutils doesn't have the ability to change compilers
    # based on source extension: we add it.
    def _compile(obj, src, ext, cc_args, extra_postargs, pp_opts):
        if osp.splitext(src)[1] == '.cu':
            # use the cuda for .cu files
            self.set_executable('compiler_so', 'nvcc')
            # use only a subset of the extra_postargs, which are 1-1 translated
            # from the extra_compile_args in the Extension class
            postargs = extra_postargs['nvcc']
        else:
            postargs = extra_postargs['cc']

        super(obj, src, ext, cc_args, postargs, pp_opts)
        # reset the default compiler_so, which we might have changed for cuda
        self.compiler_so = default_compiler_so

    # inject our redefined _compile method into the class
    self._compile = _compile 
开发者ID:dingjiansw101,项目名称:AerialDetection,代码行数:37,代码来源:setup.py

示例15: __init__

# 需要导入模块: import setuptools [as 别名]
# 或者: from setuptools import Extension [as 别名]
def __init__(self, name, build_targets, sourcedir=''):
        setuptools.Extension.__init__(self, name, sources=[])
        self.sourcedir = os.path.abspath(sourcedir)
        self.build_targets = build_targets 
开发者ID:pfnet-research,项目名称:chainer-compiler,代码行数:6,代码来源:setup.py


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