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