Skip to content

A single variable to override base folder for user_*_dir functions #374

@Czaki

Description

@Czaki

Extension of #347

When working on a caching of cache directory between sessions on CI I found that I could easily overwrite the cache directory location on Linux (using XDG_CACHE_DIR)

Then I cannot overwrite it on macOS without overwriting the whole $HONE.

@property
def user_cache_dir(self) -> str:
""":return: cache directory tied to the user, e.g. ``~/Library/Caches/$appname/$version``"""
return self._append_app_name_and_version(os.path.expanduser("~/Library/Caches")) # noqa: PTH111

It looks like there is an option to overwrite it on Windows:

@property
def user_cache_dir(self) -> str:
"""
:return: cache directory tied to the user (if opinionated with ``Cache`` folder within ``$appname``) e.g.
``%USERPROFILE%\\AppData\\Local\\$appauthor\\$appname\\Cache\\$version``
"""
path = os.path.normpath(get_win_folder("CSIDL_LOCAL_APPDATA"))
return self._append_parts(path, opinion_value="Cache")

(will have access to a Windows machine in a few days, then could check)

But it will really simplify CI configuration if there is one environment variable respected on all OS. For example: PLATFORMDIR_CACHE_DIR. (And similar variables for other directories)

What did you think about such a feature? Will you accept such a contribution?

Related PR that brings me this idea: napari/napari#8235

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions