TNO Intern

Optionally read pacakge version from toml file in case no virtual environment is used.

Read version name from pyprojects.toml file in case CSO to support running outside virtual environment.

Merge request reports

Loading
+12 −1
Changes for src/cso/__init__.py: 12 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -108,9 +108,20 @@ and are defined according to the following hierchy:
# -------------------------------------------------

# store version number:
try:
    from importlib import metadata

    __version__ = metadata.version(__package__)
except:
    import os
    if "CSO_PREFIX" in os.environ.keys():
        import tomllib
        with open(os.path.join(os.environ["CSO_PREFIX"],"pyproject.toml"),"rb") as f :
            pp = tomllib.load( f )
        __version__ = pp["project"]["version"]
    else:
        __version__ = "x.y"
    #endif
#endtry

# import entities from sub-modules:
from .cso_file import *
Loading