Recommit pull request due to build failure.

After random failures during build, and my failing to rebase properly,
I have re-committed the code that was used in this previous pull
request: https://github.com/astropy/astropy/pull/2103