Commit 73c635b9 authored by Martin Bauer's avatar Martin Bauer
Browse files

Better default paths for config and cache using appdirs module

parent abb11958
......@@ -8,7 +8,8 @@ except ImportError:
from joblib import Memory
diskcache = Memory(cachedir="/tmp/pystencils/joblib_memcache", verbose=False).cache
from appdirs import user_cache_dir
diskcache = Memory(cachedir=user_cache_dir('pystencils'), verbose=False).cache
except ImportError:
# fallback to in-memory caching if joblib is not available
diskcache = memorycache(maxsize=64)
......@@ -69,6 +69,7 @@ import platform
import glob
import atexit
import shutil
from appdirs import user_config_dir, user_cache_dir
from ctypes import cdll
from pystencils.backends.cbackend import generateC, getHeaders
from collections import OrderedDict, Mapping
......@@ -142,10 +143,7 @@ def _recursiveDictUpdate(d, u):
def getConfigurationFilePath():
if platform.system().lower() == 'linux':
configPathInHome = os.path.expanduser(os.path.join("~", '.config', 'pystencils', 'config.json'))
configPathInHome = os.path.expanduser(os.path.join("~", '.pystencils', 'config.json'))
configPathInHome = os.path.join(user_config_dir('pystencils'), 'config.json')
# 1) Read path from environment variable if found
if 'PYSTENCILS_CONFIG' in os.environ:
......@@ -177,12 +175,7 @@ def readConfig():
('flags', '-Ofast -DNDEBUG -fPIC -march=native -fopenmp -std=c++11'),
('restrictQualifier', '__restrict__')
defaultCacheConfig = OrderedDict([
('readFromSharedLibrary', False),
('objectCache', '/tmp/pystencils/objectcache'),
('clearCacheOnStart', False),
('sharedLibrary', '/tmp/pystencils/'),
elif platform.system().lower() == 'windows':
defaultCompilerConfig = OrderedDict([
('os', 'windows'),
......@@ -191,12 +184,12 @@ def readConfig():
('flags', '/Ox /fp:fast /openmp /arch:avx'),
('restrictQualifier', '__restrict')
defaultCacheConfig = OrderedDict([
('readFromSharedLibrary', False),
('objectCache', os.path.join('~', '.pystencils', 'objectcache')),
('clearCacheOnStart', False),
('sharedLibrary', os.path.join('~', '.pystencils', 'cache.dll')),
defaultCacheConfig = OrderedDict([
('readFromSharedLibrary', False),
('objectCache', os.path.join(user_cache_dir('pystencils'), 'objectcache')),
('clearCacheOnStart', False),
('sharedLibrary', os.path.join(user_cache_dir('pystencils'), '')),
defaultConfig = OrderedDict([('compiler', defaultCompilerConfig),
('cache', defaultCacheConfig)])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment