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


Python ExternalCompilationInfo.convert_sources_to_files方法代码示例

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


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

示例1: test_convert_sources_to_c_files

# 需要导入模块: from rpython.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from rpython.translator.tool.cbuild.ExternalCompilationInfo import convert_sources_to_files [as 别名]
 def test_convert_sources_to_c_files(self):
     eci = ExternalCompilationInfo(
         separate_module_sources = ['xxx'],
         separate_module_files = ['x.c'],
     )
     cache_dir = udir.join('test_convert_sources').ensure(dir=1)
     neweci = eci.convert_sources_to_files(cache_dir)
     assert not neweci.separate_module_sources
     res = neweci.separate_module_files
     assert len(res) == 2
     assert res[0] == 'x.c'
     assert str(res[1]).startswith(str(cache_dir))
     e = ExternalCompilationInfo()
     assert e.convert_sources_to_files() is e
开发者ID:Darriall,项目名称:pypy,代码行数:16,代码来源:test_cbuild.py

示例2: compile_extension_module

# 需要导入模块: from rpython.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from rpython.translator.tool.cbuild.ExternalCompilationInfo import convert_sources_to_files [as 别名]
def compile_extension_module(space, modname, **kwds):
    """
    Build an extension module and return the filename of the resulting native
    code file.

    modname is the name of the module, possibly including dots if it is a module
    inside a package.

    Any extra keyword arguments are passed on to ExternalCompilationInfo to
    build the module (so specify your source with one of those).
    """
    state = space.fromcache(State)
    api_library = state.api_lib
    if sys.platform == 'win32':
        kwds["libraries"] = [api_library]
        # '%s' undefined; assuming extern returning int
        kwds["compile_extra"] = ["/we4013"]
        # prevent linking with PythonXX.lib
        w_maj, w_min = space.fixedview(space.sys.get('version_info'), 5)[:2]
        kwds["link_extra"] = ["/NODEFAULTLIB:Python%d%d.lib" %
                              (space.int_w(w_maj), space.int_w(w_min))]
    elif sys.platform == 'darwin':
        kwds["link_files"] = [str(api_library + '.dylib')]
    else:
        kwds["link_files"] = [str(api_library + '.so')]
        if sys.platform.startswith('linux'):
            kwds["compile_extra"]=["-Werror=implicit-function-declaration",
                                   "-g", "-O0"]
            kwds["link_extra"]=["-g"]

    modname = modname.split('.')[-1]
    eci = ExternalCompilationInfo(
        include_dirs=api.include_dirs,
        **kwds
        )
    eci = eci.convert_sources_to_files()
    dirname = (udir/uniquemodulename('module')).ensure(dir=1)
    soname = platform.platform.compile(
        [], eci,
        outputfilename=str(dirname/modname),
        standalone=False)
    from pypy.module.imp.importing import get_so_extension
    pydname = soname.new(purebasename=modname, ext=get_so_extension(space))
    soname.rename(pydname)
    return str(pydname)
开发者ID:abhinavthomas,项目名称:pypy,代码行数:47,代码来源:test_cpyext.py

示例3: ExternalCompilationInfo

# 需要导入模块: from rpython.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from rpython.translator.tool.cbuild.ExternalCompilationInfo import convert_sources_to_files [as 别名]
cdir = py.path.local(cdir)

eci = ExternalCompilationInfo(
    include_dirs = [cdir],
    includes = ['src/stacklet/stacklet.h'],
    separate_module_files = [cdir / 'src' / 'stacklet' / 'stacklet.c'],
)
if 'masm' in dir(eci.platform): # Microsoft compiler
    if is_emulated_long:
        asmsrc = 'switch_x64_msvc.asm'
    else:
        asmsrc = 'switch_x86_msvc.asm'
    eci.separate_module_files += (cdir / 'src' / 'stacklet' / asmsrc, )

rffi_platform.verify_eci(eci.convert_sources_to_files())

def llexternal(name, args, result, **kwds):
    return rffi.llexternal(name, args, result, compilation_info=eci,
                           _nowrapper=True, **kwds)

# ----- types -----

handle = rffi.COpaquePtr(typedef='stacklet_handle', compilation_info=eci)
thread_handle = rffi.COpaquePtr(typedef='stacklet_thread_handle',
                                compilation_info=eci)
run_fn = lltype.Ptr(lltype.FuncType([handle, llmemory.Address], handle))

# ----- constants -----

null_handle = lltype.nullptr(handle.TO)
开发者ID:Darriall,项目名称:pypy,代码行数:32,代码来源:_rffi_stacklet.py


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