diff --git a/__init__.py b/__init__.py index c01d7d8..2de44ef 100644 --- a/__init__.py +++ b/__init__.py @@ -1,6 +1,7 @@ import logging -from bpy.app import background, version +from bpy.app import background, version_string +from .utilities import get_min_blender_version bl_info = { "name": "CAD Sketcher", @@ -16,11 +17,11 @@ } # Check user's Blender version against minimum required Blender version for add-on. -blender_v = bl_info["blender"] -if version < blender_v: +blender_v_min = get_min_blender_version() +if version_string < blender_v_min: raise Exception( "This add-on is only compatible with Blender versions " - f"{blender_v[0]}.{blender_v[1]}.{blender_v[2]} or greater.\n" + f"{blender_v_min[0]}.{blender_v_min[1]}.{blender_v_min[2]} or greater.\n" ) from . import global_data diff --git a/blender_manifest.toml b/blender_manifest.toml index ad30e47..97b8e9f 100644 --- a/blender_manifest.toml +++ b/blender_manifest.toml @@ -13,7 +13,7 @@ website = "https://www.cadsketcher.com/" tags = ["3D View", "Modeling", "Mesh", "Object"] -blender_version_min = "4.2.0" +blender_version_min = "3.3.0" license = [ "SPDX:GPL-3.0-or-later", diff --git a/utilities/__init__.py b/utilities/__init__.py index f766e98..0d4d0ac 100644 --- a/utilities/__init__.py +++ b/utilities/__init__.py @@ -6,5 +6,14 @@ def get_addon_version(): manifest = pathlib.Path(__file__).parent.parent / "blender_manifest.toml" try: return toml.load(manifest)["version"] + except Exception: + return "" + +def get_min_blender_version(): + """Returns the minimal required blender version from manifest file""" + + manifest = pathlib.Path(__file__).parent.parent / "blender_manifest.toml" + try: + return toml.load(manifest)["blender_version_min"] except Exception: return "" \ No newline at end of file