astropy/astropy — pull request #142 by iguananaut (2013-01-07 23:12:58+00:00)
Title: get_distutils_option() doesn't always work with custom command options

Because `get_distutils_option()` uses the distutils machinery to parse the command line options, part of that machinery involves loading the classes for each distutils command being executed and inspecting those classes for the command line arguments they accept.

The problem is that we override some built-in commands and add additional options--the custom 'test' command in particular comes to mind. I was running into a problem where I was using the `-a` option with test, which we added. The problem is that if `get_distutils_option()` is called *before* the custom command has been registered with distutils, distutils throws up an exception upon seeing the unrecognized option for the `test` command. That exception is already caught, but it causes `get_distutils_option()` to return `None`.

Not sure yet what the best solution is.