Ejemplo n.º 1
0
                    close(fd)
                    unlink(name)

            return result

    _memimporter = MemImporter()
    builtin_memimporter = _memimporter.ready

modules = {}
remote_load_package = None
remote_print_error = None

try:
    import pupy
    if not (hasattr(pupy, 'pseudo') and pupy.pseudo) and not modules:
        modules = pupy.get_modules()
except ImportError:
    pass

def get_module_files(fullname):
    """ return the file to load """
    global modules
    path = fullname.replace('.','/')

    files = [
        module for module in modules.iterkeys() \
        if module.rsplit(".",1)[0] == path or any([
            path+'/__init__'+ext == module for ext in [
                '.py', '.pyc', '.pyo'
            ]
        ])
Ejemplo n.º 2
0
                    close(fd)
                    unlink(name)

            return result

    _memimporter = MemImporter()
    builtin_memimporter = _memimporter.ready

modules = {}
remote_load_package = None
remote_print_error = None

try:
    import pupy
    if not (hasattr(pupy, 'pseudo') and pupy.pseudo) and not modules:
        modules = pupy.get_modules()
except ImportError:
    pass


def get_module_files(fullname):
    """ return the file to load """
    global modules
    path = fullname.replace('.', '/')

    files = [
        module for module in modules.iterkeys() \
        if module.rsplit(".",1)[0] == path or any([
            path+'/__init__'+ext == module for ext in [
                '.py', '.pyc', '.pyo'
            ]
Ejemplo n.º 3
0
    import _memimporter
    builtin_memimporter = True
    allow_system_packages = False

except ImportError:
    builtin_memimporter = False
    allow_system_packages = True
    dprint('_memimporter load fail')
    raise ImportError

modules = {}

try:
    import pupy
    if not (hasattr(pupy, 'pseudo') and pupy.pseudo) and not modules:
        modules = pupy.get_modules()  # [filename,file]
except ImportError:
    dprint('pupy load fail')
    pass


def pupy_add_package(pkdic, compressed=False, name=None):
    """ update the modules dictionary to allow remote imports of new packages """
    import cPickle
    import zlib

    global modules

    if compressed:
        pkdic = zlib.decompress(pkdic)