You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pyasdf's setup.py ends up importing astropy.units for reasons that aren't entirely good (so I plan to fix that). But this worked until #3389, when astropy.units is no longer importable during setup, because:
When _ASTROPY_SETUP_ is in builtins (it's set in the setup.py in the package template) [1] the NUMPY_LT_X_X constants don't get imported into astropy.utils.compat [2], then when astropy.units.quantity tries to use one of those constants [3], it blows up.
I was a little bothered about the fact that those constants are undefined in that context. But it didn't break Astropy itself so I forged ahead. And it made sense as it was, since in _ASTROPY_SETUP_ it's assumed that dependencies like Numpy might not be available.
What I could do is enhance the minversion function to accept a module name as a string instead of (or in addition to) an actual module object. Then it can handle the importing of that module, and if that fails just return False (since obviously the minimum version requirement has not been satisfied if the dependency doesn't exist at all).
@embray - I think the fix in #3479 is reasonable, but your logic above is not: if minversion returns False if the import fails, then all the strings NUMPY_LT_..., which are defined as some not minversion(...) will return True. Logically, I think one should let ImportError be raised.
Activity
embray commentedon Feb 10, 2015
I was a little bothered about the fact that those constants are undefined in that context. But it didn't break Astropy itself so I forged ahead. And it made sense as it was, since in
_ASTROPY_SETUP_it's assumed that dependencies like Numpy might not be available.What I could do is enhance the
minversionfunction to accept a module name as a string instead of (or in addition to) an actual module object. Then it can handle the importing of that module, and if that fails just return False (since obviously the minimum version requirement has not been satisfied if the dependency doesn't exist at all).mhvk commentedon Feb 11, 2015
@embray - I think the fix in #3479 is reasonable, but your logic above is not: if
minversionreturnsFalseif the import fails, then all the stringsNUMPY_LT_..., which are defined as somenot minversion(...)will returnTrue. Logically, I think one should letImportErrorbe raised.