astropy/astropy — pull request #1269 by iguananaut (2013-07-18 21:45:07+00:00)
Title: Raise an ImportError rather than call sys.exit() when astropy can't be imported from a source checkout

In #864 I added a little feature to raise a helpful error message when trying to import astropy from a source checkout before having built the extension modules inplace. Annoyingly, in my previous implementation I called `sys.exit(1)`, but that's bitten me a few times now where I `import astropy` later in session and lose other work that I've done.

With this PR, an `ImportError` is raised instead and the python session stays active. It also does some cleanup of `sys.modules` and the `logging` module so that subsequent attempts to `import astropy` will either show the same behavior or (if one opened another terminal and built the extension modules) it will succeed to import. That is, with this fix I'm able to re-build astropy and re-import it successfully without having to leave an ongoing interactive session.