Skip to content

Commit aea5e7e

Browse files
committed
Fixes issue #864 reasonably well; you'll still get a traceback if some extension modules outright failed to compile--that is, this doesn't help with a broken installation. Just with the not too uncommon case of someone trying to 'import astropy' from a source checkout
1 parent 9da7b0f commit aea5e7e

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

‎CHANGES.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ Other Changes and Additions
114114
- ``ConfigurationItem``\s now have a more useful and informative ``__repr__``
115115
and improved documentation for how to use them. [#855]
116116

117+
- Added a friendlier error message when trying to import astropy from a source
118+
checkout without first building the extension modules inplace. [#864]
119+
117120
- ``py.test`` now outputs more system information for help in debugging issues
118121
from users. [#869]
119122

‎astropy/__init__.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,24 @@ def test(package=None, test_path=None, args=None, plugins=None,
121121
from . import config
122122

123123
import os
124+
import sys
124125
from warnings import warn
125126

127+
try:
128+
from .utils import _compiler
129+
except ImportError:
130+
if os.path.exists('setup.py'):
131+
log.error('You appear to be trying to import astropy from within '
132+
'a source checkout; please run `./setup.py develop` or '
133+
'`./setup.py --inplace` first so that extension '
134+
'modules can be compiled and made importable.')
135+
sys.exit(1)
136+
else:
137+
# Outright broken installation; don't be nice.
138+
raise
139+
140+
141+
126142
# add these here so we only need to cleanup the namespace at the end
127143
config_dir = None
128144

0 commit comments

Comments
 (0)