def detectPthImportedPackages():
    if not hasattr(sys.modules["site"], "getsitepackages"):
        return ()

    pth_imports = set()

    for prefix in sys.modules["site"].getsitepackages():
        if not Utils.isDir(prefix):
            continue

        for path, filename in Utils.listDir(prefix):
            if filename.endswith(".pth"):
                try:
                    for line in open(path, "rU"):
                        if line.startswith("import "):
                            if ';' in line:
                                line = line[:line.find(';')]

                            for part in line[7:].split(','):
                                pth_imports.add(part.strip())
                except __HOLE__:
                    warning("Python installation problem, cannot read file '%s'.")


    return tuple(sorted(pth_imports))
dataset/ETHPy150Open kayhayen/Nuitka/nuitka/importing/PreloadedPackages.py/detectPthImportedPackages