Previously, because of the multiple instances of `from foo import *`, names were
imported from modules that had themselves imported them, instead of from the
place of definition. This commit therefore does the following:
- Declares `__all__` in every module that imports anything, so that
`from foo import *` is sane.
- Sorts the imports based on conventions, similar to the output of `isort`.
- Places all conditional imports after unconditional imports, except where that
isn't valid.
- Imports local names from the modules where they are defined, except when
importing the package itself.