-
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid toml import in blender version < 4.20
- Loading branch information
Showing
2 changed files
with
20 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "" |