hyb
2025-12-31 6cdcd01f77e11b72c323603e27ebdb85b15223c9
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
modulegraph.find_modules - High-level module dependency finding interface
=========================================================================
 
History
........
 
Originally (loosely) based on code in py2exe's build_exe.py by Thomas Heller.
"""
import os
import pkgutil
 
from .modulegraph import Alias
 
def get_implies():
    def _xml_etree_modules():
        import xml.etree
        return [
            f"xml.etree.{module_name}"
            for _, module_name, is_package in pkgutil.iter_modules(xml.etree.__path__)
            if not is_package
        ]
 
    result = {
        # imports done from C code in built-in and/or extension modules
        # (untrackable by modulegraph).
        "_curses": ["curses"],
        "posix": ["resource"],
        "gc": ["time"],
        "time": ["_strptime"],
        "datetime": ["time"],
        "parser": ["copyreg"],
        "codecs": ["encodings"],
        "_sre": ["copy", "re"],
        "zipimport": ["zlib"],
 
        # _frozen_importlib is part of the interpreter itself
        "_frozen_importlib": None,
 
        # os.path is an alias for a platform specific module,
        # ensure that the graph shows this.
        "os.path": Alias(os.path.__name__),
 
        # Python >= 3.2:
        "_datetime": ["time", "_strptime"],
        "_json": ["json.decoder"],
        "_pickle": ["codecs", "copyreg", "_compat_pickle"],
        "_posixsubprocess": ["gc"],
        "_ssl": ["socket"],
 
        # Python >= 3.3:
        "_elementtree": ["pyexpat"] + _xml_etree_modules(),
 
        # This is not C extension, but it uses __import__
        "anydbm": ["dbhash", "gdbm", "dbm", "dumbdbm", "whichdb"],
 
        # Known package aliases
        "wxPython.wx": Alias('wx'),
    }
 
    return result