21 lines
848 B
Python
21 lines
848 B
Python
import json
|
|
import os
|
|
from pathlib import Path
|
|
|
|
|
|
def load_config(path=None):
|
|
project=Path(__file__).resolve().parents[2]
|
|
config_path=Path(path or os.environ.get('EXOPLASIM_CONFIG', project/'config/web.json')).resolve()
|
|
config=json.loads(config_path.read_text())
|
|
config['_path']=str(config_path)
|
|
config['_project_root']=str(project)
|
|
root=Path(config['storage']['root'])
|
|
if not root.is_absolute():
|
|
root=project/root
|
|
config['_paths']={key:str((root/value).resolve()) for key,value in config['storage'].items() if key!='root'}
|
|
python=Path(config['python'])
|
|
config['_python']=str(python if python.is_absolute() else project/python)
|
|
config['_runtime_python']=str(Path(config['_paths']['runtime'])/'python')
|
|
config['_package_path']=str(Path(config['_runtime_python'])/'exoplasim')
|
|
return config
|