Skip to content

Commit

Permalink
Avoid toml import in blender version < 4.20
Browse files Browse the repository at this point in the history
  • Loading branch information
hlorus committed Apr 8, 2024
1 parent 40f18b8 commit 866bb5b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from bpy.app import background, version_string
from .utilities import get_min_blender_version

global bl_info
bl_info = {
"name": "CAD Sketcher",
"author": "hlorus",
Expand Down
23 changes: 19 additions & 4 deletions utilities/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
import pathlib, toml
from bpy.app import version
import pathlib

def get_addon_version():
def get_bl_info():

from .. import bl_info
return bl_info


def get_addon_version() -> str:
"""Return addon version from manifest file"""

if version < (4, 20):
return str(get_bl_info()["version"])

manifest = pathlib.Path(__file__).parent.parent / "blender_manifest.toml"
try:
return toml.load(manifest)["version"]
import toml
return toml.load(manifest)["blender"]
except Exception:
return ""

def get_min_blender_version():
def get_min_blender_version() -> str:
"""Returns the minimal required blender version from manifest file"""

if version < (4, 20):
return str(get_bl_info()["version"])

manifest = pathlib.Path(__file__).parent.parent / "blender_manifest.toml"
try:
import toml
return toml.load(manifest)["blender_version_min"]
except Exception:
return ""

0 comments on commit 866bb5b

Please sign in to comment.