Skip to content

Commit

Permalink
Wip using __loader__ to get module
Browse files Browse the repository at this point in the history
  • Loading branch information
jenshnielsen committed Aug 23, 2023
1 parent 1388d16 commit f3de894
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion qcodes/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check failure on line 14 in qcodes/_version.py

View workflow job for this annotation

GitHub Actions / pytestmypy (ubuntu-latest, 3.10)

Cannot access member "parent" for type "Traversable"   Member "parent" is unknown (reportGeneralTypeIssues)


Expand Down
5 changes: 3 additions & 2 deletions qcodes/configuration/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"required": []
}

_PARENT_MODULE = ".".join(__loader__.name.split(".")[:-1])

class Config:
"""
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion qcodes/monitor/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f3de894

Please sign in to comment.