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


Python build_ext.build_ext方法代码示例

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


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

示例1: run

# 需要导入模块: from setuptools.command import build_ext [as 别名]
# 或者: from setuptools.command.build_ext import build_ext [as 别名]
def run(self):
        if build.get_nvcc_path() is not None:
            def wrap_new_compiler(func):
                def _wrap_new_compiler(*args, **kwargs):
                    try:
                        return func(*args, **kwargs)
                    except errors.DistutilsPlatformError:
                        if not PLATFORM_WIN32:
                            CCompiler = _UnixCCompiler
                        else:
                            CCompiler = _MSVCCompiler
                        return CCompiler(
                            None, kwargs['dry_run'], kwargs['force'])
                return _wrap_new_compiler
            ccompiler.new_compiler = wrap_new_compiler(ccompiler.new_compiler)
            # Intentionally causes DistutilsPlatformError in
            # ccompiler.new_compiler() function to hook.
            self.compiler = 'nvidia'
        if cython_available:
            ext_modules = get_ext_modules(True)  # get .pyx modules
            cythonize(ext_modules, cupy_setup_options)
        check_extensions(self.extensions)
        build_ext.build_ext.run(self) 
开发者ID:cupy,项目名称:cupy,代码行数:25,代码来源:cupy_setup_build.py

示例2: test_abi3_filename

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

示例3: test_get_ext_filename

# 需要导入模块: from setuptools.command import build_ext [as 别名]
# 或者: from setuptools.command.build_ext import build_ext [as 别名]
def test_get_ext_filename(self):
        # setuptools needs to give back the same
        # result than distutils, even if the fullname
        # is not in ext_map
        dist = Distribution()
        cmd = build_ext(dist)
        cmd.ext_map['foo/bar'] = ''
        res = cmd.get_ext_filename('foo')
        wanted = distutils_build_ext.get_ext_filename(cmd, 'foo')
        assert res == wanted 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:12,代码来源:test_build_ext.py

示例4: __init__

# 需要导入模块: from setuptools.command import build_ext [as 别名]
# 或者: from setuptools.command.build_ext import build_ext [as 别名]
def __init__(self, *args, **kwargs):
        from setuptools.command.build_ext import build_ext as SetupToolsBuildExt

        # Bypass __setatrr__ to avoid infinite recursion.
        self.__dict__['_command'] = SetupToolsBuildExt(*args, **kwargs) 
开发者ID:weecology,项目名称:DeepForest,代码行数:7,代码来源:setup.py

示例5: config_setup_kwargs

# 需要导入模块: from setuptools.command import build_ext [as 别名]
# 或者: from setuptools.command.build_ext import build_ext [as 别名]
def config_setup_kwargs(setup_kwargs, build_chainerx):

    # TODO(imanishi): Call this function with setuptools.
    emit_build_info(build_chainerx)

    if not build_chainerx:
        # `chainerx` package needs to be able to be imported even if ChainerX
        # is unavailable.
        setup_kwargs['packages'] += ['chainerx']
        return

    if sys.version_info < (3, 5):
        raise RuntimeError(
            'ChainerX is only available for Python 3.5 or later.')
    setup_kwargs['packages'] += [
        'chainerx',
        'chainerx._docs',
        'chainerx.creation',
        'chainerx.manipulation',
        'chainerx.math',
        'chainerx.random',
        'chainerx.testing',
    ]
    setup_kwargs['package_data'] = {
        'chainerx': ['py.typed', '*.pyi'],
    }

    setup_kwargs.update(dict(
        cmdclass={'build_ext': CMakeBuild},
        ext_modules=[CMakeExtension(
            name='chainerx._core',
            build_targets=['_core.so'],
            sourcedir='chainerx_cc')],
    )) 
开发者ID:chainer,项目名称:chainer,代码行数:36,代码来源:chainerx_build_helper.py

示例6: _get_build_ext_cls

# 需要导入模块: from setuptools.command import build_ext [as 别名]
# 或者: from setuptools.command.build_ext import build_ext [as 别名]
def _get_build_ext_cls(base: Type[_build_ext], root: str) -> Type[_build_ext]:
    attrs = {'build_extension': _get_build_extension_method(base, root)}
    return type('build_ext', (base,), attrs) 
开发者ID:asottile,项目名称:setuptools-golang,代码行数:5,代码来源:setuptools_golang.py

示例7: set_build_ext

# 需要导入模块: from setuptools.command import build_ext [as 别名]
# 或者: from setuptools.command.build_ext import build_ext [as 别名]
def set_build_ext(
        dist: Distribution,
        attr: str,
        value: Dict[str, str],
) -> None:
    root = value['root']
    # https://github.com/python/typeshed/pull/3742
    base = dist.cmdclass.get('build_ext', _build_ext)  # type: ignore
    dist.cmdclass['build_ext'] = _get_build_ext_cls(base, root)  # type: ignore 
开发者ID:asottile,项目名称:setuptools-golang,代码行数:11,代码来源:setuptools_golang.py

示例8: run

# 需要导入模块: from setuptools.command import build_ext [as 别名]
# 或者: from setuptools.command.build_ext import build_ext [as 别名]
def run(self):
    for ext in self.extensions:
      self.bazel_build(ext)
    build_ext.build_ext.run(self) 
开发者ID:deepmind,项目名称:tree,代码行数:6,代码来源:setup.py

示例9: test_get_ext_filename

# 需要导入模块: from setuptools.command import build_ext [as 别名]
# 或者: from setuptools.command.build_ext import build_ext [as 别名]
def test_get_ext_filename(self):
        """
        Setuptools needs to give back the same
        result as distutils, even if the fullname
        is not in ext_map.
        """
        dist = Distribution()
        cmd = build_ext(dist)
        cmd.ext_map['foo/bar'] = ''
        res = cmd.get_ext_filename('foo')
        wanted = orig.build_ext.get_ext_filename(cmd, 'foo')
        assert res == wanted 
开发者ID:pypa,项目名称:setuptools,代码行数:14,代码来源:test_build_ext.py

示例10: __init__

# 需要导入模块: from setuptools.command import build_ext [as 别名]
# 或者: from setuptools.command.build_ext import build_ext [as 别名]
def __init__(self, name):
    # don't invoke the original build_ext for this special extension
    super().__init__(name, sources=[]) 
开发者ID:google-research,项目名称:football,代码行数:5,代码来源:setup.py

示例11: run

# 需要导入模块: from setuptools.command import build_ext [as 别名]
# 或者: from setuptools.command.build_ext import build_ext [as 别名]
def run(self):
        self.run_command("build_ext")
        self.create_version_file()
        setuptools.command.build_py.build_py.run(self) 
开发者ID:ANTsX,项目名称:ANTsPy,代码行数:6,代码来源:setup.py

示例12: __init__

# 需要导入模块: from setuptools.command import build_ext [as 别名]
# 或者: from setuptools.command.build_ext import build_ext [as 别名]
def __init__(self, *args, **kwargs):
		from setuptools.command.build_ext import build_ext as SetupToolsBuildExt

		# Bypass __setatrr__ to avoid infinite recursion.
		self.__dict__['_command'] = SetupToolsBuildExt(*args, **kwargs) 
开发者ID:fizyr,项目名称:tf-retinanet,代码行数:7,代码来源:setup.py

示例13: run

# 需要导入模块: from setuptools.command import build_ext [as 别名]
# 或者: from setuptools.command.build_ext import build_ext [as 别名]
def run(self):
        """
        Copy libraries from the bin directory and place them as appropriate
        """

        self.announce("Moving library files", level=3)

        # We have already built the libraries in the previous build_ext step

        self.skip_build = True

        bin_dir = self.distribution.bin_dir

        libs = [os.path.join(bin_dir, _lib) for _lib in 
                os.listdir(bin_dir) if 
                os.path.isfile(os.path.join(bin_dir, _lib)) and 
                os.path.splitext(_lib)[1] in [".dll", ".so"]
                and not (_lib.startswith("python") or _lib.startswith("bpy"))]

        for lib in libs:

            shutil.move(lib, os.path.join(self.build_dir,
                                          os.path.basename(lib)))

        # Mark the libs for installation, adding them to 
        # distribution.data_files seems to ensure that setuptools' record 
        # writer appends them to installed-files.txt in the package's egg-info
        #
        # Also tried adding the libraries to the distribution.libraries list, 
        # but that never seemed to add them to the installed-files.txt in the 
        # egg-info, and the online recommendation seems to be adding libraries 
        # into eager_resources in the call to setup(), which I think puts them 
        # in data_files anyways. 
        # 
        # What is the best way?

        self.distribution.data_files = [os.path.join(self.install_dir, 
                                                     os.path.basename(lib))
                                        for lib in libs]

        # Must be forced to run after adding the libs to data_files

        self.distribution.run_command("install_data")

        super().run() 
开发者ID:TylerGubala,项目名称:blenderpy,代码行数:47,代码来源:setup.py

示例14: _get_build_extension_method

# 需要导入模块: from setuptools.command import build_ext [as 别名]
# 或者: from setuptools.command.build_ext import build_ext [as 别名]
def _get_build_extension_method(
        base: Type[_build_ext],
        root: str,
) -> Callable[[_build_ext, Extension], None]:
    def build_extension(self: _build_ext, ext: Extension) -> None:
        # If there are no .go files then the parent should handle this
        if not any(source.endswith('.go') for source in ext.sources):
            # the base class may mutate `self.compiler`
            compiler = copy.deepcopy(self.compiler)
            self.compiler, compiler = compiler, self.compiler
            try:
                return base.build_extension(self, ext)
            finally:
                self.compiler, compiler = compiler, self.compiler

        if len(ext.sources) != 1:
            raise OSError(
                f'Error building extension `{ext.name}`: '
                f'sources must be a single file in the `main` package.\n'
                f'Recieved: {ext.sources!r}',
            )

        main_file, = ext.sources
        if not os.path.exists(main_file):
            raise OSError(
                f'Error building extension `{ext.name}`: '
                f'{main_file} does not exist',
            )
        main_dir = os.path.dirname(main_file)

        # Copy the package into a temporary GOPATH environment
        with _tmpdir() as tempdir:
            root_path = os.path.join(tempdir, 'src', root)
            # Make everything but the last directory (copytree interface)
            os.makedirs(os.path.dirname(root_path))
            shutil.copytree('.', root_path, symlinks=True)
            pkg_path = os.path.join(root_path, main_dir)

            env = {'GOPATH': tempdir}
            cmd_get = ('go', 'get', '-d')
            _check_call(cmd_get, cwd=pkg_path, env=env)

            env.update({
                'CGO_CFLAGS': _get_cflags(
                    self.compiler, ext.define_macros or (),
                ),
                'CGO_LDFLAGS': _get_ldflags(),
            })
            cmd_build = (
                'go', 'build', '-buildmode=c-shared',
                '-o', os.path.abspath(self.get_ext_fullpath(ext.name)),
            )
            _check_call(cmd_build, cwd=pkg_path, env=env)

    return build_extension 
开发者ID:asottile,项目名称:setuptools-golang,代码行数:57,代码来源:setuptools_golang.py


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