diff --git a/utilities/__init__.py b/utilities/__init__.py index d3137261..f016c09f 100644 --- a/utilities/__init__.py +++ b/utilities/__init__.py @@ -7,19 +7,28 @@ def get_bl_info(): return bl_info -def get_addon_version() -> str: - """Return addon version from manifest file""" +def get_addon_version_tuple() -> tuple: + """Return addon version as a tuple e.g. (0, 27, 1)""" if version < (4, 20): - return str(get_bl_info()["version"]) + return get_bl_info()["version"] manifest = pathlib.Path(__file__).parent.parent / "blender_manifest.toml" try: import toml - return toml.load(manifest)["blender"] + version_tuple = toml.load(manifest)["version"] + return tuple(map(int, version_tuple.split("."))) except Exception: return "" + +def get_addon_version() -> str: + """Return addon version as string""" + + version = get_addon_version_tuple() + return ".".join(map(str, version)) + + def get_min_blender_version() -> str: """Returns the minimal required blender version from manifest file""" diff --git a/versioning.py b/versioning.py index 3437066d..f3e3a2af 100644 --- a/versioning.py +++ b/versioning.py @@ -1,12 +1,12 @@ import bpy import logging -from .utilities import get_addon_version +from .utilities import get_addon_version_tuple logger = logging.getLogger(__name__) def write_addon_version(context): - version = get_addon_version() + version = get_addon_version_tuple() logger.debug("Writing addon version: " + str(version)) @@ -46,7 +46,7 @@ def do_versioning(self): # blender version this file was saved with file_version = bpy.data.version # Current addon version - current_addon_version = get_addon_version() + current_addon_version = get_addon_version_tuple() # "Blender Version: ", current_version, # "\nFile Blender Version: ", file_version, # "\nAddon Version: ", current_addon_version,