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


Python build_ext.build_ext方法代码示例

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


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

示例1: initialize_options

# 需要导入模块: from distutils.command import build_ext [as 别名]
# 或者: from distutils.command.build_ext import build_ext [as 别名]
def initialize_options(self):
        # initialize_options() may be called multiple times on the
        # same command object, so make sure not to override previously
        # set options.
        if getattr(self, '_initialized', False):
            return

        super(build_ext, self).initialize_options()

        if os.environ.get('EDGEDB_DEBUG'):
            self.cython_always = True
            self.cython_annotate = True
            self.cython_directives = "linetrace=True"
            self.define = 'PG_DEBUG,CYTHON_TRACE,CYTHON_TRACE_NOGIL'
            self.debug = True
        else:
            self.cython_always = False
            self.cython_annotate = None
            self.cython_directives = None
            self.debug = False 
开发者ID:edgedb,项目名称:edgedb,代码行数:22,代码来源:setup.py

示例2: prepare_extensions

# 需要导入模块: from distutils.command import build_ext [as 别名]
# 或者: from distutils.command.build_ext import build_ext [as 别名]
def prepare_extensions(self):
        """
        Prepare the C{self.extensions} attribute (used by
        L{build_ext.build_ext}) by checking which extensions in
        L{conditionalExtensions} should be built.  In addition, if we are
        building on NT, define the WIN32 macro to 1.
        """
        # always define WIN32 under Windows
        if os.name == 'nt':
            self.define_macros = [("WIN32", 1)]
        else:
            self.define_macros = []
        self.extensions = [x for x in self.conditionalExtensions
                           if x.condition(self)]
        for ext in self.extensions:
            ext.define_macros.extend(self.define_macros) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:18,代码来源:dist.py

示例3: find_library_file

# 需要导入模块: from distutils.command import build_ext [as 别名]
# 或者: from distutils.command.build_ext import build_ext [as 别名]
def find_library_file(libname):
    """
    Try to get the directory of the specified library.
    It adds to the search path the library paths given to distutil's build_ext.
    """
    # Use a dummy argument parser to get user specified library dirs
    parser = argparse.ArgumentParser(add_help=False)
    parser.add_argument("--library-dirs", "-L", default='')
    args, unknown = parser.parse_known_args()
    lib_dirs = args.library_dirs.split(':')

    if 'LD_LIBRARY_PATH' in os.environ:
        lib_dirs += os.environ['LD_LIBRARY_PATH'].split(':')

    # Append default search path (not a complete list)
    lib_dirs += [join(sys.prefix, 'lib'),
                 '/usr/local/lib',
                 '/usr/lib64',
                 '/usr/lib',
                 '/usr/lib/x86_64-linux-gnu']

    compiler = ccompiler.new_compiler()
    return compiler.find_library_file(lib_dirs, libname) 
开发者ID:casacore,项目名称:python-casacore,代码行数:25,代码来源:setup.py

示例4: initialize_options

# 需要导入模块: from distutils.command import build_ext [as 别名]
# 或者: from distutils.command.build_ext import build_ext [as 别名]
def initialize_options(self):
        # initialize_options() may be called multiple times on the
        # same command object, so make sure not to override previously
        # set options.
        if getattr(self, '_initialized', False):
            return

        super(build_ext, self).initialize_options()

        if os.environ.get('ASYNCPG_DEBUG'):
            self.cython_always = True
            self.cython_annotate = True
            self.cython_directives = "linetrace=True"
            self.define = 'PG_DEBUG,CYTHON_TRACE,CYTHON_TRACE_NOGIL'
            self.debug = True
        else:
            self.cython_always = False
            self.cython_annotate = None
            self.cython_directives = None 
开发者ID:MagicStack,项目名称:asyncpg,代码行数:21,代码来源:setup.py

示例5: test_record_extensions

# 需要导入模块: from distutils.command import build_ext [as 别名]
# 或者: from distutils.command.build_ext import build_ext [as 别名]
def test_record_extensions(self):
        install_dir = self.mkdtemp()
        project_dir, dist = self.create_dist(ext_modules=[
            Extension('xx', ['xxmodule.c'])])
        os.chdir(project_dir)
        support.copy_xxmodule_c(project_dir)

        buildextcmd = build_ext(dist)
        support.fixup_build_ext(buildextcmd)
        buildextcmd.ensure_finalized()

        cmd = install(dist)
        dist.command_obj['install'] = cmd
        dist.command_obj['build_ext'] = buildextcmd
        cmd.root = install_dir
        cmd.record = os.path.join(project_dir, 'filelist')
        cmd.ensure_finalized()
        cmd.run()

        f = open(cmd.record)
        try:
            content = f.read()
        finally:
            f.close()

        found = [os.path.basename(line) for line in content.splitlines()]
        expected = [_make_ext_name('xx'),
                    'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]]
        self.assertEqual(found, expected) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:31,代码来源:test_install.py

示例6: run

# 需要导入模块: from distutils.command import build_ext [as 别名]
# 或者: from distutils.command.build_ext import build_ext [as 别名]
def run(self):
        if self.distribution.rust_extensions:
            distutils.log.info("running build_rust")
            _check_rust()
            build_rust = self.get_finalized_command("build_rust")
            build_ext = self.get_finalized_command("build_ext")
            copy_list = []
            if not self.inplace:
                for ext in self.distribution.rust_extensions:
                    # Always build in-place because later stages of the build
                    # may depend on the modules having been built
                    dylib_path = pathlib.Path(
                        build_ext.get_ext_fullpath(ext.name))
                    build_ext.inplace = True
                    target_path = pathlib.Path(
                        build_ext.get_ext_fullpath(ext.name))
                    build_ext.inplace = False
                    copy_list.append((dylib_path, target_path))

                    # Workaround a bug in setuptools-rust: it uses
                    # shutil.copyfile(), which is not safe w.r.t mmap,
                    # so if the target module has been previously loaded
                    # bad things will happen.
                    if target_path.exists():
                        target_path.unlink()

                    target_path.parent.mkdir(parents=True, exist_ok=True)

            build_rust.debug = self.debug
            os.environ['CARGO_TARGET_DIR'] = (
                str(pathlib.Path(self.build_temp) / 'rust' / 'extensions'))
            build_rust.run()

            for src, dst in copy_list:
                shutil.copyfile(src, dst)

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

示例7: _patch_for_target

# 需要导入模块: from distutils.command import build_ext [as 别名]
# 或者: from distutils.command.build_ext import build_ext [as 别名]
def _patch_for_target(patchlist, target):
    from distutils.command.build_ext import build_ext
    # if 'target' is different from '*', we need to patch some internal
    # method to just return this 'target' value, instead of having it
    # built from module_name
    if target.endswith('.*'):
        target = target[:-2]
        if sys.platform == 'win32':
            target += '.dll'
        elif sys.platform == 'darwin':
            target += '.dylib'
        else:
            target += '.so'
    _patch_meth(patchlist, build_ext, 'get_ext_filename',
                lambda self, ext_name: target) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:17,代码来源:recompiler.py

示例8: _get_build_extension

# 需要导入模块: from distutils.command import build_ext [as 别名]
# 或者: from distutils.command.build_ext import build_ext [as 别名]
def _get_build_extension(self):
        self._clear_distutils_mkpath_cache()
        dist = Distribution()
        config_files = dist.find_config_files()
        try:
            config_files.remove('setup.cfg')
        except ValueError:
            pass
        dist.parse_config_files(config_files)
        build_extension = build_ext(dist)
        build_extension.finalize_options()
        return build_extension 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:14,代码来源:cythonmagic.py

示例9: prepare_extensions

# 需要导入模块: from distutils.command import build_ext [as 别名]
# 或者: from distutils.command.build_ext import build_ext [as 别名]
def prepare_extensions(self):
        """
        Prepare the C{self.extensions} attribute (used by
        L{build_ext.build_ext}) by checking which extensions in
        I{conditionalExtensions} should be built.  In addition, if we are
        building on NT, define the WIN32 macro to 1.
        """
        # always define WIN32 under Windows
        if os.name == 'nt':
            self.define_macros = [("WIN32", 1)]
        else:
            self.define_macros = []

        # On Solaris 10, we need to define the _XOPEN_SOURCE and
        # _XOPEN_SOURCE_EXTENDED macros to build in order to gain access to
        # the msg_control, msg_controllen, and msg_flags members in
        # sendmsg.c. (according to
        # http://stackoverflow.com/questions/1034587).  See the documentation
        # of X/Open CAE in the standards(5) man page of Solaris.
        if sys.platform.startswith('sunos'):
            self.define_macros.append(('_XOPEN_SOURCE', 1))
            self.define_macros.append(('_XOPEN_SOURCE_EXTENDED', 1))

        self.extensions = [
            x for x in self.conditionalExtensions if x.condition(self)
        ]

        for ext in self.extensions:
            ext.define_macros.extend(self.define_macros) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:31,代码来源:_setup.py

示例10: build_extensions

# 需要导入模块: from distutils.command import build_ext [as 别名]
# 或者: from distutils.command.build_ext import build_ext [as 别名]
def build_extensions(self):
        """
        Check to see which extension modules to build and then build them.
        """
        self.prepare_extensions()
        build_ext.build_ext.build_extensions(self) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:8,代码来源:_setup.py

示例11: test_distutils_api_2

# 需要导入模块: from distutils.command import build_ext [as 别名]
# 或者: from distutils.command.build_ext import build_ext [as 别名]
def test_distutils_api_2(self):
        self._make_distutils_api()
        self.run(["setup.py", "build_ext", "-i"])
        self.check_produced_files({'setup.py': None,
                                   'build': '?',
                                   'src': {'pack1': {'__init__.py': None,
                                                     'mymod.SO': None}}}) 
开发者ID:johncsnyder,项目名称:SwiftKitten,代码行数:9,代码来源:test_zdist.py

示例12: test_setuptools_abi_2

# 需要导入模块: from distutils.command import build_ext [as 别名]
# 或者: from distutils.command.build_ext import build_ext [as 别名]
def test_setuptools_abi_2(self):
        self._make_setuptools_abi()
        self.run(["setup.py", "build_ext", "-i"])
        self.check_produced_files({'setup.py': None,
                                   'src0': {'pack2': {'__init__.py': None,
                                                      '_build.py': None,
                                                      'mymod.py': None}}}) 
开发者ID:johncsnyder,项目名称:SwiftKitten,代码行数:9,代码来源:test_zdist.py

示例13: _make_setuptools_api

# 需要导入模块: from distutils.command import build_ext [as 别名]
# 或者: from distutils.command.build_ext import build_ext [as 别名]
def _make_setuptools_api(self):
        self._prepare_setuptools()
        os.mkdir("src1")
        os.mkdir(os.path.join("src1", "pack3"))
        with open(os.path.join("src1", "pack3", "__init__.py"), "w") as f:
            pass
        with open(os.path.join("src1", "pack3", "_build.py"), "w") as f:
            f.write("""if 1:
                import cffi
                ffi = cffi.FFI()
                ffi.set_source("pack3.mymod", "/*code would be here*/")
                ffi._hi_there = 42
            """)
        with open("setup.py", "w") as f:
            f.write("from __future__ import print_function\n"
                """if 1:
                from setuptools import setup
                from distutils.command.build_ext import build_ext
                import os

                class TestBuildExt(build_ext):
                    def pre_run(self, ext, ffi):
                        print('_make_setuptools_api: in pre_run:', end=" ")
                        assert ffi._hi_there == 42
                        assert ext.name == "pack3.mymod"
                        fn = os.path.join(os.path.dirname(self.build_lib),
                                          '..', 'see_me')
                        print('creating %r' % (fn,))
                        open(fn, 'w').close()

                setup(name='example1',
                      version='0.1',
                      packages=['pack3'],
                      package_dir={'': 'src1'},
                      cffi_modules=["src1/pack3/_build.py:ffi"],
                      cmdclass={'build_ext': TestBuildExt},
                      )
            """) 
开发者ID:johncsnyder,项目名称:SwiftKitten,代码行数:40,代码来源:test_zdist.py

示例14: test_setuptools_api_2

# 需要导入模块: from distutils.command import build_ext [as 别名]
# 或者: from distutils.command.build_ext import build_ext [as 别名]
def test_setuptools_api_2(self):
        self._make_setuptools_api()
        self.run(["setup.py", "build_ext", "-i"])
        self.check_produced_files({'setup.py': None,
                                   'build': '?',
                                   'see_me': None,
                                   'src1': {'pack3': {'__init__.py': None,
                                                      '_build.py': None,
                                                      'mymod.SO': None}}}) 
开发者ID:johncsnyder,项目名称:SwiftKitten,代码行数:11,代码来源:test_zdist.py

示例15: test_record_extensions

# 需要导入模块: from distutils.command import build_ext [as 别名]
# 或者: from distutils.command.build_ext import build_ext [as 别名]
def test_record_extensions(self):
        cmd = test_support.missing_compiler_executable()
        if cmd is not None:
            self.skipTest('The %r command is not found' % cmd)
        install_dir = self.mkdtemp()
        project_dir, dist = self.create_dist(ext_modules=[
            Extension('xx', ['xxmodule.c'])])
        os.chdir(project_dir)
        support.copy_xxmodule_c(project_dir)

        buildextcmd = build_ext(dist)
        support.fixup_build_ext(buildextcmd)
        buildextcmd.ensure_finalized()

        cmd = install(dist)
        dist.command_obj['install'] = cmd
        dist.command_obj['build_ext'] = buildextcmd
        cmd.root = install_dir
        cmd.record = os.path.join(project_dir, 'filelist')
        cmd.ensure_finalized()
        cmd.run()

        f = open(cmd.record)
        try:
            content = f.read()
        finally:
            f.close()

        found = [os.path.basename(line) for line in content.splitlines()]
        expected = [_make_ext_name('xx'),
                    'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]]
        self.assertEqual(found, expected) 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:34,代码来源:test_install.py


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