TNO Intern

Commit 38f364f6 authored by Arjo Segers's avatar Arjo Segers
Browse files

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

parent af3d2346
Loading
Loading
Loading
Loading
+14 −3
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 *