def dig_wheel()

in gazelle/modules_mapping/generator.py [0:0]


    def dig_wheel(self, whl):
        mapping = {}
        wheel_name = get_wheel_name(whl)
        with zipfile.ZipFile(whl, "r") as zip_file:
            for path in zip_file.namelist():
                if is_metadata(path):
                    continue
                ext = pathlib.Path(path).suffix
                if ext == ".py" or ext == ".so":
                    # Note the '/' here means that the __init__.py is not in the
                    # root of the wheel, therefore we can index the directory
                    # where this file is as an importable package.
                    if path.endswith("/__init__.py"):
                        module = path[: -len("/__init__.py")].replace("/", ".")
                        mapping[module] = wheel_name
                    # Always index the module file.
                    if ext == ".so":
                        # Also remove extra metadata that is embeded as part of
                        # the file name as an extra extension.
                        ext = "".join(pathlib.Path(path).suffixes)
                    module = path[: -len(ext)].replace("/", ".")
                    mapping[module] = wheel_name
        return mapping