Debian Codegraph @

pypy/module/zipimport/moduledef.py

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