Skip to content

Commit

Permalink
Lookup minimal required version from blender_manifest.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
hlorus committed Apr 8, 2024
1 parent e0123b1 commit 40f18b8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
9 changes: 5 additions & 4 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion blender_manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 9 additions & 0 deletions utilities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""

0 comments on commit 40f18b8

Please sign in to comment.