def _get_standard_modules():
    """ Return list of module names in the Python standard library. """
    # Find library directories.
    if sys.platform == 'win32':  #pragma no cover
        lib_dir = os.path.join(sys.prefix, 'Lib')
        obj_dir = os.path.join(sys.prefix, 'DLLs')
        obj_pattern = '*.dll'
        roots = [lib_dir, obj_dir]
    else:
        lib_dir = os.path.join(sys.prefix, 'lib', 'python'+sys.version[0:3])
        obj_dir = 'lib-dynload'
        obj_pattern = '*.so'
        roots = [lib_dir]

    # Find 'real' sys.prefix (not that of virtualenv).
    orig_prefix = None

    try:
        with open(os.path.join(lib_dir, 'orig-prefix.txt'), 'r') as inp:
            orig_prefix = inp.read()
    except IOError as error:
        pass

    # Add to roots.
    if orig_prefix:
        for root in tuple(roots):
            roots.append(orig_prefix + root[len(sys.prefix):])

    # Now scan for modules.
    excludes = set(sys.builtin_module_names)
    for root in roots:
        for dirpath, dirnames, filenames in os.walk(root):
            if 'test' in dirnames:
                dirnames.remove('test')
            if dirpath == root:
                path = ''
                if 'site-packages' in dirnames:
                    dirnames.remove('site-packages')
            else:
                path = dirpath[len(root)+1:]
                if path == obj_dir:
                    path = ''
            for name in filenames:
                if fnmatch.fnmatch(name, '*.py*') or \
                   fnmatch.fnmatch(name, obj_pattern):
                    name = os.path.join(path, name[:name.rfind('.')])
                    name = name.replace(os.sep, '.')
                    if name.endswith('.__init__'):
                        name = name[:name.rfind('.')]
                    excludes.add(name)

    return list(excludes)
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.util/src/openmdao/util/eggsaver.py/_get_standard_modules/original