diff --git a/mriqc/cli/version.py b/mriqc/cli/version.py index acfe36f3..9cb381ac 100644 --- a/mriqc/cli/version.py +++ b/mriqc/cli/version.py @@ -24,11 +24,10 @@ from contextlib import suppress from datetime import datetime, timezone -from pathlib import Path import requests -from mriqc import __version__ +from mriqc import __version__, config RELEASE_EXPIRY_DAYS = 14 DATE_FMT = '%Y%m%d' @@ -42,7 +41,7 @@ def check_latest(): latest = None date = None outdated = None - cachefile = Path.home() / '.cache' / 'mriqc' / 'latest' + cachefile = config.environment.cache_path / 'latest' try: cachefile.parent.mkdir(parents=True, exist_ok=True) except OSError: diff --git a/mriqc/config.py b/mriqc/config.py index 4f1fe616..ff838d0b 100644 --- a/mriqc/config.py +++ b/mriqc/config.py @@ -212,6 +212,11 @@ else '18480913-163000_PhineasG-ageh-adhi-sacc-ident9b1ab0f' ) +_mriqc_cache = Path(os.getenv( + 'MRIQC_CACHE_PATH', + str(Path.home() / '.cache' / 'mriqc') +)).absolute() + class _Config: """An abstract class forbidding instantiation.""" @@ -283,6 +288,8 @@ class environment(_Config): """ + cache_path = _mriqc_cache + """Path to the location of the cache directory.""" cpu_count = os.cpu_count() """Number of available CPUs.""" exec_docker_version = _docker_ver