Skip to content

When to install compatibility packages #194

Closed

Description

@astrofrog

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

  1. ghost assigned on Apr 8, 2012
  2. astrofrog commented on Apr 8, 2012

    @astrofrog
    MemberAuthor

    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.

  3. mdboom commented on Apr 9, 2012

    @mdboom
    Contributor

    This logic got screwed up in some recent changes. See #193 for a fix.

  4. astrofrog commented on Apr 18, 2012

    @astrofrog
    MemberAuthor

    This is fixed now that #193 is merged - thanks!

  5. added a commit that references this issue on Jun 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions