docs: def check_extract_from_egg(pth, todir=None):
      r"""
      Check if path points to a file inside a python egg file, extract the
      file from the egg to a cache directory (following pkg_resources
      convention) and return [(extracted path, egg file path, relative path
      inside egg file)].
      Otherwise, just return [(original path, None, None)].
      If path points to an egg file directly, return a list with all files
      from the egg formatted like above.
  
      Example:
      >>> check_extract_from_egg(r'C:\Python26\Lib\site-packages\my.egg\mymodule\my.pyd')
      [(r'C:\Users\UserName\AppData\Roaming\Python-Eggs\my.egg-tmp\mymodule\my.pyd',
      r'C:\Python26\Lib\site-packages\my.egg', r'mymodule/my.pyd')]
      """
      rv = []
      if os.path.altsep:
          pth = pth.replace(os.path.altsep, os.path.sep)
      components = pth.split(os.path.sep)
      for i, name in enumerate(components):
          if name.lower().endswith(".egg"):
              eggpth = os.path.sep.join(components[:i + 1])
              if os.path.isfile(eggpth):
                  # eggs can also be directories!
                  try:
                      egg = zipfile.ZipFile(eggpth)
                  except zipfile.BadZipfile, e:
                      raise SystemExit("Error: %s %s" % (eggpth, e))
                  if todir is None:
                      # Use the same directory as setuptools/pkg_resources. So,
                      # if the specific egg was accessed before (not necessarily
                      # by pyinstaller), the extracted contents already exist
                      # (pkg_resources puts them there) and can be used.
                      todir = os.path.join(pkg_resouces_get_default_cache(),
                                           name + "-tmp")
                  if components[i + 1:]:
                      members = ["/".join(components[i + 1:])]
                  else:
                      members = egg.namelist()
                  for member in members:
                      pth = os.path.join(todir, member)
                      if not os.path.isfile(pth):
                          dirname = os.path.dirname(pth)
                          if not os.path.isdir(dirname):
                              os.makedirs(dirname)
                          f = open(pth, "wb")
                          f.write(egg.read(member))
                          f.close()
                      rv.append((pth, eggpth, member))
                  return rv
      return [(pth, None, None)]