Extra test for MY_CONFIG variable; fix order import for stub/dynamic config

This commit is contained in:
Dima Gerasimov 2020-05-05 08:18:08 +01:00 committed by karlicoss
parent 636060db57
commit 6d1fba2171
4 changed files with 61 additions and 30 deletions

View file

@ -43,14 +43,16 @@ def setup_config():
return
mpath = str(mycfg_dir)
if mpath not in sys.path:
sys.path.insert(0, mpath)
# NOTE: we _really_ want to have mpath in front there, to shadow my.config stub within this packages
# hopefully it doesn't cause any issues
sys.path.insert(0, mpath)
# remove the stub and insert reimport hte 'real' config
if 'my.config' in sys.modules:
# TODO FIXME make sure this method isn't called twice...
del sys.modules['my.config']
try:
# todo import_from instead?? dunno
import my.config
except ImportError as ex:
# just in case... who knows what crazy setup users have in mind.