Skip to content

ENH: (gradually) evolving astropy's config and cache directory discovery system #18964

Description

@neutrinoceros

This is the follow up, uber-issue, to #17934 (and a legacy sequel to #10738).

In that PR, we ended up taking an extremely cautious path to preserve bug-for-bug compatibility with the existing (hereafter, "legacy") behavior. This exceptional level of caution is justified for a piece of software we know is relied on in high-stakes downstream packages such as astroquery and sunpy.

However, and as hopefully made evident with #17934, as well as the backlog of issues related to this piece of software, the legacy behavior is causing a lot of hassle, which I'll try to summarize (tentatively, in an exhaustive fashion) here:

  • It's very brittle (env vars just end up being ignored in many cases)
    • in particular, it's not platform portable (windows is explicitly not supported at all)
  • Even when not ignored, env vars lead to surprising behavior (the global config/cache directories from $HOME/.astropy are never truly shadowed, but merely linked-to)
  • It is extremely difficult to test (and in turn, to maintain)
  • It excludes some actually useful features from our design space, like

My conclusion is that, in order to overcome all of these problems, we should attempt to overhaul the entire logic, albeit at a very gradual pace.
The new behavior should, first and foremost, be easy to predict, use, and test, but it should also leave room for at least some of the features I listed above.

I propose the following schedule:

  • astropy 7.2 only gets UX: warn when env variables are ignored in cache and config directory discovery #17934: exact same behavior as 7.1, with one key difference that env vars are never ignored silently
  • early during 8.0's dev cycle, introduce a much simpler (albeit possibly backward-breaking) fundamental
  • if the new design survives in some form until 8.0.0rc1, release it there, but explicitly reserve the possibility to change course
  • if no major issue is reported during the pre-release phase, ship the new design as part of 8.0.0 final
  • allow for new features (e.g. the ones I listed above) in 8.1

Activity

  1. added this to the v8.0.0 milestone on Nov 18, 2025
  2. changed the title [-]ENH: (gradual) evolving astropy's config and cache directory discovery system[/-] [+]ENH: (gradually) evolving astropy's config and cache directory discovery system[/+] on Nov 18, 2025
  3. pllim commented on Nov 24, 2025

    @pllim
    Member

    early during 8.0's dev cycle, introduce a much simpler (albeit possibly backward-breaking) fundamental

    We are here now. Do you have more specifics on what you plan to propose for this phase?

  4. neutrinoceros commented on Nov 24, 2025

    @neutrinoceros
    ContributorAuthor

    Yes, but my proposal is so radically simple that a PoC PR would do just as well as a description, I think. I can work it out tomorrow.

  5. neutrinoceros commented on Apr 25, 2026

    @neutrinoceros
    ContributorAuthor

    I can work it out tomorrow.

    lol. Took me almost six months just to get started on it, and even though the bulk of the code was written over 2 days, it took me two weeks to get it fully functional. Anyway this is now at #19575

  6. astrofrog commented on Apr 25, 2026

    @astrofrog
    Member

    Just curious, in the long term does it make sense to try and converge towards the same behavior as https://github.com/tox-dev/platformdirs so that we can just use that instead?

  7. neutrinoceros commented on Apr 25, 2026

    @neutrinoceros
    ContributorAuthor

    I don't see what value it'd add TBH, especially for the (IMO significant) cost of adding a new dependency. It doesn't seem like it'd replace a significant part of our system (wether the legacy one or my proposed new one).

  8. neutrinoceros commented on Apr 25, 2026

    @neutrinoceros
    ContributorAuthor

    (Maybe it'd help for Android or iOS, but I'd probably still rather implement support for these if ever needed rather than adding a dependency)

  9. neutrinoceros commented on Apr 25, 2026

    @neutrinoceros
    ContributorAuthor

    Besides, I think that by adhering to the XDG spec more closely in #19575 we are already converging our behavior with platformdirs, at least for Linux and MacOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions