From 52b94decf13e9311fb52663d5db114317458cf06 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Wed, 9 Nov 2022 13:51:11 +0100 Subject: [PATCH] Wip using __loader__ to get module --- qcodes/_version.py | 4 +++- qcodes/configuration/config.py | 5 +++-- qcodes/monitor/monitor.py | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/qcodes/_version.py b/qcodes/_version.py index 3979205fa20..165bcea6084 100644 --- a/qcodes/_version.py +++ b/qcodes/_version.py @@ -8,7 +8,9 @@ def _get_version() -> str: import versioningit - qcodes_path = files("qcodes") + root_module = __loader__.name.split(".")[0] + + qcodes_path = files(root_module) return versioningit.get_version(project_dir=qcodes_path.parent) diff --git a/qcodes/configuration/config.py b/qcodes/configuration/config.py index 44ce1fba4b8..605d95af2e7 100644 --- a/qcodes/configuration/config.py +++ b/qcodes/configuration/config.py @@ -32,6 +32,7 @@ "required": [] } +_PARENT_MODULE = ".".join(__loader__.name.split(".")[:-1]) class Config: """ @@ -47,14 +48,14 @@ class Config: schema_file_name = "qcodesrc_schema.json" """Name of schema file""" # get abs path of packge config file - default_file_name = str(files("qcodes.configuration") / config_file_name) + default_file_name = str(files(_PARENT_MODULE) / config_file_name) """Filename of default config""" current_config_path = default_file_name """Path of the last loaded config file""" _loaded_config_files = [default_file_name] # get abs path of schema file - schema_default_file_name = str(files("qcodes.configuration") / schema_file_name) + schema_default_file_name = str(files(_PARENT_MODULE) / schema_file_name) """Filename of default schema""" # home dir, os independent diff --git a/qcodes/monitor/monitor.py b/qcodes/monitor/monitor.py index 39ba502ca21..468e080df09 100644 --- a/qcodes/monitor/monitor.py +++ b/qcodes/monitor/monitor.py @@ -273,7 +273,9 @@ def main() -> None: # If this file is run, create a simple webserver that serves a simple # website that can be used to view monitored parameters. - static_dir = files("qcodes.monitor.dist") + parent_module = ".".join(__loader__.name.split(".")[:-1]) + + static_dir = files(parent_module).joinpath("dist") try: with as_file(static_dir) as extracted_dir: os.chdir(extracted_dir)