From f5b786edce6d12d6963443b2b2b823e867a6d231 Mon Sep 17 00:00:00 2001
From: Christian Godenschwager <christian.godenschwager@fau.de>
Date: Wed, 29 Nov 2017 12:53:10 +0100
Subject: [PATCH] Allow to set cache directory via environment variable

---
 cache.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/cache.py b/cache.py
index 4732fa39d..78a7c56a8 100644
--- a/cache.py
+++ b/cache.py
@@ -1,5 +1,6 @@
 import sympy as sp
 import json
+import os
 
 try:
     from functools import lru_cache as memorycache
@@ -9,7 +10,11 @@ except ImportError:
 try:
     from joblib import Memory
     from appdirs import user_cache_dir
-    diskcache = Memory(cachedir=user_cache_dir('pystencils'), verbose=False).cache
+    if 'PYSTENCILS_CACHE_DIR' in os.environ:
+        cacheDir = os.environ['PYSTENCILS_CACHE_DIR']
+    else:
+        cacheDir = user_cache_dir('pystencils')
+    diskcache = Memory(cachedir=cacheDir, verbose=False).cache
 except ImportError:
     # fallback to in-memory caching if joblib is not available
     diskcache = memorycache(maxsize=64)
-- 
GitLab