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


Python cbuild.ExternalCompilationInfo类代码示例

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


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

示例1: try_tools

def try_tools():
    try:
        yield ExternalCompilationInfo.from_pkg_config("ncurses")
    except Exception:
        pass
    try:
        yield ExternalCompilationInfo.from_config_tool("ncurses5-config")
    except Exception:
        pass
开发者ID:charred,项目名称:pypy,代码行数:9,代码来源:fficurses.py

示例2: test_convert_sources_to_c_files

 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,代码行数:14,代码来源:test_cbuild.py

示例3: test_from_linker_flags

 def test_from_linker_flags(self):
     flags = ('-L/some/lib/path -L/other/lib/path '
              '-lmylib1 -lmylib2 -?1 -!2')
     eci = ExternalCompilationInfo.from_linker_flags(flags)
     assert eci.libraries == ('mylib1', 'mylib2')
     assert eci.library_dirs == ('/some/lib/path',
                                 '/other/lib/path')
     assert eci.link_extra == ('-?1', '-!2')
开发者ID:Darriall,项目名称:pypy,代码行数:8,代码来源:test_cbuild.py

示例4: test_merge2

 def test_merge2(self):
     e1 = ExternalCompilationInfo(
         pre_include_bits  = ['1'],
         link_files = ['1.c']
     )
     e2 = ExternalCompilationInfo(
         pre_include_bits  = ['2'],
         link_files = ['1.c', '2.c']
     )
     e3 = ExternalCompilationInfo(
         pre_include_bits  = ['3'],
         link_files = ['1.c', '2.c', '3.c']
     )
     e = e1.merge(e2)
     e = e.merge(e3, e3)
     assert e.pre_include_bits == ('1', '2', '3')
     assert e.link_files == ('1.c', '2.c', '3.c')
开发者ID:Darriall,项目名称:pypy,代码行数:17,代码来源:test_cbuild.py

示例5: compile_extension_module

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,代码行数:45,代码来源:test_cpyext.py

示例6: test_platforms

    def test_platforms(self):
        from rpython.translator.platform import Platform

        class Maemo(Platform):
            def __init__(self, cc=None):
                self.cc = cc
        
        eci = ExternalCompilationInfo(platform=Maemo())
        eci2 = ExternalCompilationInfo()
        assert eci != eci2
        assert hash(eci) != hash(eci2)
        assert repr(eci) != repr(eci2)
        py.test.raises(Exception, eci2.merge, eci)
        assert eci.merge(eci).platform == Maemo()
        assert (ExternalCompilationInfo(platform=Maemo(cc='xxx')) !=
                ExternalCompilationInfo(platform=Maemo(cc='yyy')))
        assert (repr(ExternalCompilationInfo(platform=Maemo(cc='xxx'))) !=
                repr(ExternalCompilationInfo(platform=Maemo(cc='yyy'))))
开发者ID:Darriall,项目名称:pypy,代码行数:18,代码来源:test_cbuild.py

示例7: test_from_compiler_flags

 def test_from_compiler_flags(self):
     flags = ('-I/some/include/path -I/other/include/path '
              '-DMACRO1 -D_MACRO2=baz -?1 -!2')
     eci = ExternalCompilationInfo.from_compiler_flags(flags)
     assert eci.pre_include_bits == ('#define MACRO1 1',
                                     '#define _MACRO2 baz')
     assert eci.includes == ()
     assert eci.include_dirs == ('/some/include/path',
                                 '/other/include/path')
     assert eci.compile_extra == ('-?1', '-!2')
开发者ID:Darriall,项目名称:pypy,代码行数:10,代码来源:test_cbuild.py

示例8: test_merge

 def test_merge(self):
     e1 = ExternalCompilationInfo(
         pre_include_bits   = ['1'],
         includes           = ['x.h'],
         post_include_bits  = ['p1']
     )
     e2 = ExternalCompilationInfo(
         pre_include_bits   = ['2'],
         includes           = ['x.h', 'y.h'],
         post_include_bits  = ['p2'],
     )
     e3 = ExternalCompilationInfo(
         pre_include_bits   = ['3'],
         includes           = ['y.h', 'z.h'],
         post_include_bits  = ['p1', 'p3']
     )
     e = e1.merge(e2, e3)
     assert e.pre_include_bits == ('1', '2', '3')
     assert e.includes == ('x.h', 'y.h', 'z.h')
     assert e.post_include_bits == ('p1', 'p2', 'p3')
开发者ID:Darriall,项目名称:pypy,代码行数:20,代码来源:test_cbuild.py

示例9: test_from_pkg_config

 def test_from_pkg_config(self):
     try:
         cmd = ['pkg-config', 'ncurses', '--exists']
         popen = Popen(cmd)
         result = popen.wait()
     except OSError:
         result = -1
     if result != 0:
         py.test.skip("failed: %r" % (' '.join(cmd),))
     eci = ExternalCompilationInfo.from_pkg_config('ncurses')
     assert 'ncurses' in eci.libraries
开发者ID:Darriall,项目名称:pypy,代码行数:11,代码来源:test_cbuild.py

示例10: test_make_shared_lib

 def test_make_shared_lib(self):
     eci = ExternalCompilationInfo(
         separate_module_sources = ['''
         RPY_EXTERN int get()
         {
             return 42;
         }
         int shouldnt_export()
         {
             return 43;
         }'''],
     )
     neweci = eci.compile_shared_lib()
     assert len(neweci.libraries) == 1
     try:
         import ctypes
     except ImportError:
         py.test.skip("Need ctypes for that test")
     assert ctypes.CDLL(neweci.libraries[0]).get() == 42
     assert not hasattr(ctypes.CDLL(neweci.libraries[0]), 'shouldnt_export')
     assert not neweci.separate_module_sources
     assert not neweci.separate_module_files
开发者ID:Darriall,项目名称:pypy,代码行数:22,代码来源:test_cbuild.py

示例11: ExternalCompilationInfo

import py
from rpython.rtyper.lltypesystem import lltype, llmemory, rffi, rstr
from rpython.translator import cdir
from rpython.translator.tool.cbuild import ExternalCompilationInfo


cwd = py.path.local(__file__).dirpath()
eci = ExternalCompilationInfo(
    includes=[cwd.join('faulthandler.h')],
    include_dirs=[str(cwd), cdir],
    separate_module_files=[cwd.join('faulthandler.c')])

eci_later = eci.merge(ExternalCompilationInfo(
    pre_include_bits=['#define PYPY_FAULTHANDLER_LATER\n']))
eci_user = eci.merge(ExternalCompilationInfo(
    pre_include_bits=['#define PYPY_FAULTHANDLER_USER\n']))

def direct_llexternal(*args, **kwargs):
    kwargs.setdefault('_nowrapper', True)
    kwargs.setdefault('compilation_info', eci)
    return rffi.llexternal(*args, **kwargs)


DUMP_CALLBACK = lltype.Ptr(lltype.FuncType(
                     [rffi.INT, rffi.SIGNEDP, lltype.Signed], lltype.Void))

pypy_faulthandler_setup = direct_llexternal(
    'pypy_faulthandler_setup', [DUMP_CALLBACK], rffi.CCHARP)

pypy_faulthandler_teardown = direct_llexternal(
    'pypy_faulthandler_teardown', [], lltype.Void)
开发者ID:mozillazg,项目名称:pypy,代码行数:31,代码来源:cintf.py

示例12: str

import pixie.vm.libs.ffi as ffi
import rpython.rlib.rgc as rgc


pkgpath = py.path.local(__file__).dirpath()
srcpath = pkgpath.join("c")

shutil.copyfile(str(srcpath / "uv_ffi.c"), str(udir.udir / "uv_ffi.c"))
shutil.copyfile(str(srcpath / "uv_ffi.h"), str(udir.udir / "uv_ffi.h"))


compilation_info = ExternalCompilationInfo(
        includes=['uv.h', "ffi.h", "uv_ffi.h"],
        include_dirs=[srcpath],
        libraries=["uv", "ffi"],
        separate_module_files=[udir.udir / "uv_ffi.c"]).merge(ExternalCompilationInfo.from_pkg_config("libffi"))

def llexternal(*args, **kwargs):
    return rffi.llexternal(*args, compilation_info=compilation_info, **kwargs)


uv_work = rffi_platform.Struct("uv_work_t",
                               [("data", rffi.VOIDP)])

uv_timer_t = rffi.COpaque("uv_timer_t", compilation_info=compilation_info)
uv_baton_t = rffi.COpaque("work_baton_t", compilation_info=compilation_info)


uv_timer = lltype.Ptr(uv_timer_t)

uv_timer_cb = lltype.Ptr(lltype.FuncType([uv_timer, rffi.INT], lltype.Void))
开发者ID:andrewchambers,项目名称:pixie,代码行数:31,代码来源:uv.py

示例13: ExternalCompilationInfo

    need_rusage = False
else:
    TIME_H = 'sys/time.h'
    FTIME = 'ftime'
    STRUCT_TIMEB = 'struct timeb'
    includes = [TIME_H, 'time.h', 'errno.h', 'sys/select.h',
                'sys/types.h', 'unistd.h',
                'sys/time.h', 'sys/resource.h']

    if not sys.platform.startswith("openbsd"):
        includes.append('sys/timeb.h')

    need_rusage = True


eci = ExternalCompilationInfo(includes=includes)

class CConfig:
    _compilation_info_ = eci
    TIMEVAL = rffi_platform.Struct('struct timeval', [('tv_sec', rffi.INT),
                                                      ('tv_usec', rffi.INT)])
    HAVE_GETTIMEOFDAY = rffi_platform.Has('gettimeofday')
    HAVE_FTIME = rffi_platform.Has(FTIME)
    if need_rusage:
        RUSAGE = rffi_platform.Struct('struct rusage', [('ru_utime', TIMEVAL),
                                                        ('ru_stime', TIMEVAL)])

if sys.platform.startswith('freebsd') or sys.platform.startswith('netbsd'):
    libraries = ['compat']
elif sys.platform == 'linux2':
    libraries = ['rt']
开发者ID:cimarieta,项目名称:usp,代码行数:31,代码来源:rtime.py

示例14: dlerror

#include <string.h>
#include <stdio.h>
#include <stdlib.h>

RPY_EXPORTED
char *_pypy_init_home(void)
{
    Dl_info info;
    dlerror();   /* reset */
    if (dladdr(&_pypy_init_home, &info) == 0) {
        fprintf(stderr, "PyPy initialization: dladdr() failed: %s\n",
                dlerror());
        return NULL;
    }
    char *p = realpath(info.dli_fname, NULL);
    if (p == NULL) {
        p = strdup(info.dli_fname);
    }
    return p;
}
"""

_eci = ExternalCompilationInfo(separate_module_sources=[_source_code],
    post_include_bits=['RPY_EXPORTED char *_pypy_init_home(void);'])
_eci = _eci.merge(rdynload.eci)

pypy_init_home = rffi.llexternal("_pypy_init_home", [], rffi.CCHARP,
                                 _nowrapper=True, compilation_info=_eci)
pypy_init_free = rffi.llexternal("free", [rffi.CCHARP], lltype.Void,
                                 _nowrapper=True, compilation_info=_eci)
开发者ID:mozillazg,项目名称:pypy,代码行数:30,代码来源:initpath.py

示例15: pypy_vmprof_init

    separate_module_sources=["""
        int pypy_vmprof_init(void) {
            return vmprof_set_mainloop(pypy_execute_frame_trampoline, 0,
                                NULL);
        }
    """],
    )


if DYNAMIC_VMPROF:
    eci_kwds['libraries'] += ['vmprof']
    eci_kwds['link_extra'] = ['-Wl,-rpath,%s' % SRC, '-L%s' % SRC]
else:
    eci_kwds['separate_module_files'] += [SRC.join('vmprof.c')]

eci = ExternalCompilationInfo(**eci_kwds)

check_eci = eci.merge(ExternalCompilationInfo(separate_module_files=[
    SRC.join('fake_pypy_api.c')]))

platform.verify_eci(check_eci)

pypy_execute_frame_trampoline = rffi.llexternal(
    "pypy_execute_frame_trampoline",
    [llmemory.GCREF, llmemory.GCREF, llmemory.GCREF, lltype.Signed],
    llmemory.GCREF,
    compilation_info=eci,
    _nowrapper=True, sandboxsafe=True,
    random_effects_on_gcobjs=True)

pypy_vmprof_init = rffi.llexternal("pypy_vmprof_init", [], rffi.INT,
开发者ID:pypyjs,项目名称:pypy,代码行数:31,代码来源:interp_vmprof.py


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