def get_entry_point(self, config):
        from pypy.tool.lib_pypy import import_from_lib_pypy
        rebuild = import_from_lib_pypy('ctypes_config_cache/rebuild')
        rebuild.try_rebuild()

        space = make_objspace(config)

        # manually imports app_main.py
        filename = os.path.join(pypydir, 'interpreter', 'app_main.py')
        app = gateway.applevel(open(filename).read(), 'app_main.py', 'app_main')
        app.hidden_applevel = False
        w_dict = app.getwdict(space)
        entry_point, _ = create_entry_point(space, w_dict)

        return entry_point, None, PyPyAnnotatorPolicy()
import StringIO

from pypy.tool.lib_pypy import import_from_lib_pypy, LIB_ROOT


try:
    from rpython.translator.sandbox.vfs import Dir, File, RealDir, FSObject, RealFile
    from rpython.translator.sandbox.vfs import UID, GID
except ImportError:
    from pypy.translator.sandbox.vfs import Dir, File, RealDir, FSObject, RealFile
    from pypy.translator.sandbox.vfs import UID, GID

from twisted.internet import reactor, abstract, fdesc, defer, protocol
from twisted.python import log

marshal = import_from_lib_pypy('marshal')

TIMEOUT = 1000


# ===================================[ Sandbox Input / Output marshalling ]====================

# keep the table in sync with rsandbox.reraise_error()
EXCEPTION_TABLE = [
    (1, OSError),
    (2, IOError),
    (3, OverflowError),
    (4, ValueError),
    (5, ZeroDivisionError),
    (6, MemoryError),
    (7, KeyError),
Example #3
0
def test_import_from_lib_pypy():
    _functools = lib_pypy.import_from_lib_pypy('_functools')
    assert type(_functools) is type(lib_pypy)
    assert _functools.__name__ == 'lib_pypy._functools'
    assert hasattr(_functools, 'partial')
Example #4
0
from zipfile import ZIP_STORED, ZIP_DEFLATED
from pypy.rlib.streamio import open_file_as_stream
from pypy.rlib.rstruct.runpack import runpack
from pypy.rlib.rarithmetic import r_uint, intmask
from pypy.rpython.tool.rffi_platform import CompilationError
import os

try:
    from pypy.rlib import rzlib
except (ImportError, CompilationError):
    rzlib = None

# XXX hack to get crc32 to work
from pypy.tool.lib_pypy import import_from_lib_pypy
crc_32_tab = import_from_lib_pypy('binascii').crc_32_tab

rcrc_32_tab = [r_uint(i) for i in crc_32_tab]

def crc32(s, crc=0):
    result = 0
    crc = ~r_uint(crc) & r_uint(0xffffffffL)
    for c in s:
        crc = rcrc_32_tab[(crc ^ r_uint(ord(c))) & 0xffL] ^ (crc >> 8)
        #/* Note:  (crc >> 8) MUST zero fill on left

        result = crc ^ r_uint(0xffffffffL)

    return result

# parts copied from zipfile library implementation
Example #5
0
def test_import_from_lib_pypy():
    binascii = lib_pypy.import_from_lib_pypy('binascii')
    assert type(binascii) is type(lib_pypy)
    assert binascii.__name__ == 'lib_pypy.binascii'
    assert hasattr(binascii, 'crc_32_tab')
Example #6
0
try:
    # Preferred way since python 2.6
    from hashlib import md5
except ImportError:
    try:
        from md5 import md5
    except ImportError:
        # no _md5 module on this platform. Try hard to find a pure-python one
        # by fishing it from lib_pypy
        from pypy.tool.lib_pypy import import_from_lib_pypy
        md5 = import_from_lib_pypy('md5')
        del import_from_lib_pypy