1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
import os
from rpython.rlib.objectmodel import we_are_translated
from pypy.module._frozen_importlib.moduledef import Module as FrozenImportlibModule
from pypy.interpreter.mixedmodule import MixedModule
from pypy.module.sys import initpath
lib_python = os.path.join(os.path.dirname(__file__),
'..', '..', '..', 'lib-python', '3')
class Module(MixedModule):
interpleveldefs = {
}
appleveldefs = {
}
def install(self):
"""NOT_RPYTHON"""
from pypy.module.imp import interp_imp
super(Module, self).install()
space = self.space
FrozenImportlibModule._compile_bootstrap_module(
space, 'zipimport', self.w_name, self.w_dict,
directory=".")
def startup(self, space):
""" sys.path_hooks.insert(0, zipimporter) """
if not we_are_translated(): # add it at translation time only, will be frozen into the binary
w_path_hooks = space.sys.get("path_hooks")
w_zipimporter = self.get("zipimporter")
space.call_method(w_path_hooks, "insert", space.newint(0), w_zipimporter)
|