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


Python ExternalCompilationInfo.merge方法代码示例

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


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

示例1: test_merge2

# 需要导入模块: from rpython.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from rpython.translator.tool.cbuild.ExternalCompilationInfo import merge [as 别名]
 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,代码行数:19,代码来源:test_cbuild.py

示例2: test_platforms

# 需要导入模块: from rpython.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from rpython.translator.tool.cbuild.ExternalCompilationInfo import merge [as 别名]
    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,代码行数:20,代码来源:test_cbuild.py

示例3: test_merge

# 需要导入模块: from rpython.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from rpython.translator.tool.cbuild.ExternalCompilationInfo import merge [as 别名]
 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,代码行数:22,代码来源:test_cbuild.py

示例4: configure_external_library

# 需要导入模块: from rpython.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from rpython.translator.tool.cbuild.ExternalCompilationInfo import merge [as 别名]
def configure_external_library(name, eci, configurations,
                               symbol=None, _cache={}):
    """try to find the external library.
    On Unix, this simply tests and returns the given eci.

    On Windows, various configurations may be tried to compile the
    given eci object.  These configurations are a list of dicts,
    containing:
    
    - prefix: if an absolute path, will prefix each include and
              library directories.  If a relative path, the external
              directory is searched for directories which names start
              with the prefix.  The last one in alphabetical order
              chosen, and becomes the prefix.

    - include_dir: prefix + include_dir is added to the include directories
    
    - library_dir: prefix + library_dir is added to the library directories
    """

    if sys.platform != 'win32':
        configurations = []
    
    key = (name, eci)
    try:
        return _cache[key]
    except KeyError:
        last_error = None

        # Always try the default configuration
        if {} not in configurations:
            configurations.append({})

        for configuration in configurations:
            prefix = configuration.get('prefix', '')
            include_dir = configuration.get('include_dir', '')
            library_dir = configuration.get('library_dir', '')

            if prefix and not os.path.isabs(prefix):
                import glob

                entries = glob.glob(str(PYPY_EXTERNAL_DIR.join(prefix + '*')))
                if entries:
                    # Get last version
                    prefix = sorted(entries)[-1]
                else:
                    continue

            include_dir = os.path.join(prefix, include_dir)
            library_dir = os.path.join(prefix, library_dir)

            eci_lib = ExternalCompilationInfo(
                include_dirs=include_dir and [include_dir] or [],
                library_dirs=library_dir and [library_dir] or [],
                )
            eci_lib = eci_lib.merge(eci)

            # verify that this eci can be compiled
            try:
                verify_eci(eci_lib)
            except CompilationError, e:
                last_error = e
            else:
                _cache[key] = eci_lib
                return eci_lib

        # Nothing found
        if last_error:
            raise last_error
        else:
            raise CompilationError("Library %s is not installed" % (name,))
开发者ID:charred,项目名称:pypy,代码行数:73,代码来源:rffi_platform.py

示例5: ExternalCompilationInfo

# 需要导入模块: from rpython.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from rpython.translator.tool.cbuild.ExternalCompilationInfo import merge [as 别名]
    SYS_getrandom = None

    if sys.platform.startswith('linux'):
        eci = ExternalCompilationInfo(includes=['sys/syscall.h'])
        class CConfig:
            _compilation_info_ = eci
            SYS_getrandom = rffi_platform.DefinedConstantInteger(
                'SYS_getrandom')
        globals().update(rffi_platform.configure(CConfig))

    if SYS_getrandom is not None:
        from rpython.rlib.rposix import get_saved_errno, handle_posix_error
        import errno

        eci = eci.merge(ExternalCompilationInfo(includes=['linux/random.h']))
        class CConfig:
            _compilation_info_ = eci
            GRND_NONBLOCK = rffi_platform.ConstantInteger('GRND_NONBLOCK')
        globals().update(rffi_platform.configure(CConfig))

        # On Linux, use the syscall() function because the GNU libc doesn't
        # expose the Linux getrandom() syscall yet.
        syscall = rffi.llexternal(
            'syscall',
            [lltype.Signed, rffi.CCHARP, rffi.LONG, rffi.INT],
            lltype.Signed,
            compilation_info=eci,
            save_err=rffi.RFFI_SAVE_ERRNO)

        class Works:
开发者ID:mozillazg,项目名称:pypy,代码行数:32,代码来源:rurandom.py

示例6: vmprof_set_mainloop

# 需要导入模块: from rpython.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from rpython.translator.tool.cbuild.ExternalCompilationInfo import merge [as 别名]
            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,
                                   compilation_info=eci)
vmprof_enable = rffi.llexternal("vmprof_enable",
                                [rffi.INT, rffi.LONG, rffi.INT,
开发者ID:pypyjs,项目名称:pypy,代码行数:34,代码来源:interp_vmprof.py

示例7: dlerror

# 需要导入模块: from rpython.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from rpython.translator.tool.cbuild.ExternalCompilationInfo import merge [as 别名]
#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,代码行数:32,代码来源:initpath.py

示例8: external

# 需要导入模块: from rpython.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from rpython.translator.tool.cbuild.ExternalCompilationInfo import merge [as 别名]
    QueryPerformanceCounter = external(
        'QueryPerformanceCounter', [lltype.Ptr(A)], lltype.Void,
        releasegil=False)
    QueryPerformanceFrequency = external(
        'QueryPerformanceFrequency', [lltype.Ptr(A)], rffi.INT,
        releasegil=False)
    class State(object):
        divisor = 0.0
        counter_start = 0
    state = State()
elif CLOCK_PROCESS_CPUTIME_ID is not None:
    # Linux and other POSIX systems with clock_gettime()
    globals().update(rffi_platform.configure(CConfigForClockGetTime))
    TIMESPEC = TIMESPEC
    CLOCK_PROCESS_CPUTIME_ID = CLOCK_PROCESS_CPUTIME_ID
    eci_with_lrt = eci.merge(ExternalCompilationInfo(libraries=['rt']))
    c_clock_gettime = external('clock_gettime',
                               [lltype.Signed, lltype.Ptr(TIMESPEC)],
                               rffi.INT, releasegil=False,
                               compilation_info=eci_with_lrt)
else:
    RUSAGE = RUSAGE
    RUSAGE_SELF = RUSAGE_SELF or 0
    c_getrusage = external('getrusage',
                           [rffi.INT, lltype.Ptr(RUSAGE)],
                           lltype.Void,
                           releasegil=False)

@replace_time_function('clock')
@jit.dont_look_inside  # the JIT doesn't like FixedSizeArray
def clock():
开发者ID:cimarieta,项目名称:usp,代码行数:33,代码来源:rtime.py

示例9: ExternalCompilationInfo

# 需要导入模块: from rpython.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from rpython.translator.tool.cbuild.ExternalCompilationInfo import merge [as 别名]
config = platform.configure(CConfig)

eci = ExternalCompilationInfo(
    includes=[thisdir.join('_posixsubprocess.h')],
    include_dirs=[str(thisdir), cdir],
    separate_module_files=[thisdir.join('_posixsubprocess.c')])

compile_extra = []
if config['HAVE_SYS_SYSCALL_H']:
    compile_extra.append("-DHAVE_SYS_SYSCALL_H")
if config['HAVE_SETSID']:
    compile_extra.append("-DHAVE_SETSID")

eci = eci.merge(
    ExternalCompilationInfo(
        compile_extra=compile_extra))

c_child_exec = rffi.llexternal(
    'pypy_subprocess_child_exec',
    [rffi.CCHARPP, rffi.CCHARPP, rffi.CCHARPP, rffi.CCHARP,
     rffi.INT, rffi.INT, rffi.INT, rffi.INT, rffi.INT, rffi.INT, 
     rffi.INT, rffi.INT, rffi.INT, rffi.INT, rffi.INT,
     rffi.CArrayPtr(rffi.LONG), lltype.Signed,
     lltype.Ptr(lltype.FuncType([rffi.VOIDP], rffi.INT)), rffi.VOIDP],
    lltype.Void,
    compilation_info=eci,
    releasegil=True)
c_cloexec_pipe = rffi.llexternal(
    'pypy_subprocess_cloexec_pipe',
    [rffi.CArrayPtr(rffi.INT)], rffi.INT,
开发者ID:Qointum,项目名称:pypy,代码行数:32,代码来源:interp_subprocess.py

示例10: ExternalCompilationInfo

# 需要导入模块: from rpython.translator.tool.cbuild import ExternalCompilationInfo [as 别名]
# 或者: from rpython.translator.tool.cbuild.ExternalCompilationInfo import merge [as 别名]
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,代码行数:33,代码来源:cintf.py


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