Repository navigation
Closed
Milestone
Description
I'm confused by the Astropy behavior with compatibility packages. At the moment, if I have the genuine pyfits installed, and no astropy installation, astropy installs the legacy shim. If the legacy shim is already installed, it doesn't install it. This seems to be contradictory with the warning message:
------------------------------------------------------------
The legacy package 'vo' was found.
To install astropy's compatibility layer instead, uninstall
'vo' and then reinstall astropy.
------------------------------------------------------------
which suggests to me that the correct behavior is that if the real PyFITS is installed ('legacy package'), then the shim should not be installed, and that if people want the shim, they should uninstall the real package. However, if the installed pyfits is the legacy shim, then it should be re-installed in case it has been updated. Is that not the intended behavior? If so, the following code has the wrong logic:
found_legacy_module = False
try:
location = imp.find_module(old_package)
except ImportError:
pass
else:
# We want ImportError to raise here, because that means it was
# found, but something else went wrong.
# We could import the module here to determine if its "real"
# or just a legacy alias. However, importing the legacy alias
# may cause importing of code within the astropy source tree,
# which may require 2to3 to have been run. It's safer to just
# open the file and search for a string.
filename = os.path.join(location[1], '__init__.py')
if os.path.exists(filename):
with open(filename, 'U') as fd:
if '_is_astropy_legacy_alias' in fd.read():
found_legacy_module = True
shim_dir = os.path.join(get_legacy_alias_dir(), old_package)
if found_legacy_module:
warn('-' * 60)
warn("The legacy package '{0}' was found.".format(old_package))
warn("To install astropy's compatibility layer instead, uninstall")
warn("'{0}' and then reinstall astropy.".format(old_package))
warn('-' * 60)
if os.path.isdir(shim_dir):
shutil.rmtree(shim_dir)
return (None, None)
I think it should be:
if '_is_astropy_legacy_alias' not in fd.read():
Activity
astrofrog commentedon Apr 8, 2012
Changing this line does indeed make the installation behavior work as I would expect - I have PyFITS, vo, and pywcs already installed, so it does not install the legacy shims.
mdboom commentedon Apr 9, 2012
This logic got screwed up in some recent changes. See #193 for a fix.
astrofrog commentedon Apr 18, 2012
This is fixed now that #193 is merged - thanks!
Merge pull request astropy#194 from embray/osx-tmpdir-fix
Fix for astropy#194
Second fix for astropy#194
Third fix for astropy#194
roles complete description from json fix for astropy#194
Merge pull request astropy#225 from apooravc/simplify-role-changing