def demote(self):
    """Demote the bootstrap code to the end of the `sys.path` so it is found last.

    :return: The list of un-imported bootstrap modules.
    :rtype: list of :class:`types.ModuleType`
    """
    import sys  # Grab a hold of `sys` early since we'll be un-importing our module in this process.

    unimported_modules = []
    for name, module in reversed(sorted(sys.modules.items())):
      if self.imported_from_bootstrap(module):
        unimported_modules.append(sys.modules.pop(name))

    sys.path[:] = [path for path in sys.path if os.path.realpath(path) != self._realpath]
    sys.path.append(self._sys_path_entry)

    return unimported_modules
Demote the bootstrap code to the end of the `sys.path` so it is found last.

    :return: The list of un-imported bootstrap modules.
    :rtype: list of :class:`types.ModuleType`