File: moduledef.py

package info (click to toggle)
pypy3 7.3.19%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 212,236 kB
  • sloc: python: 2,098,316; ansic: 540,565; sh: 21,462; asm: 14,419; cpp: 4,451; makefile: 4,209; objc: 761; xml: 530; exp: 499; javascript: 314; pascal: 244; lisp: 45; csh: 12; awk: 4
file content (32 lines) | stat: -rw-r--r-- 1,135 bytes parent folder | download | duplicates (3)
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)