PAHFIT / pahfit

Model Decomposition for Near- to Mid-Infrared Spectroscopy of Astronomical Sources
https://pahfit.readthedocs.io/
18 stars 26 forks source link

Can't import pahfit since astropy 6.0.0 #268

Closed drvdputt closed 5 months ago

drvdputt commented 7 months ago

In the astropy template, which was used to set up the pahfit package, there is the file pahfit/_astropy_init.py. There is some code in there which does no longer work with astropy 6.0.0, because update_default_config was removed from astropy.config.configuration.

...

if not _ASTROPY_SETUP_:  # noqa
    import os
    from warnings import warn
    from astropy.config.configuration import (
        update_default_config,
        ConfigurationDefaultMissingError,
        ConfigurationDefaultMissingWarning,
    )

    # Create the test function for self test
    from astropy.tests.runner import TestRunner

    test = TestRunner.make_test_runner_in(os.path.dirname(__file__))
    test.__test__ = False
    __all__ += ["test"]

    # add these here so we only need to cleanup the namespace at the end
    config_dir = None

    if not os.environ.get("ASTROPY_SKIP_CONFIG_UPDATE", False):
        config_dir = os.path.dirname(__file__)
        config_template = os.path.join(config_dir, __package__ + ".cfg")
        if os.path.isfile(config_template):
            try:
                update_default_config(__package__, config_dir, version=__version__)
            except TypeError as orig_error:
                try:
                    update_default_config(__package__, config_dir)
                except ConfigurationDefaultMissingError as e:
                    wmsg = (
                        e.args[0] + " Cannot install default profile. If you are "
                        "importing from source, this is expected."
                    )
                    warn(ConfigurationDefaultMissingWarning(wmsg))
                    del e
                except Exception:
                    raise orig_error

   ...

We need to look at this code and see if there's a trivial change we can do. And then set an appropriate astropy version constraint.

As a workaround, I just commented things out everything referring to update_default_config.

karllark commented 7 months ago

I have been fixing this issue in my repositories. So can put my fix on a PR in the next day or so if that is helpful.

drvdputt commented 7 months ago

Thanks Karl, that would be very useful. I was expecting that other people already ran into this.

karllark commented 7 months ago

PR ready for review.