Fixed crash on exit with closed stdout, with thanks to Marc Abramowitz. Now uses setuptools if available, and falls back to distutils if not. setup.py no longer ...