Reputation: 184
I want to access my addon version as stored in bl_info
programatically, because I don't want to have duplicates of something that is meant to change.
I tried using addon_utils.addons_fake_modules
, but that list is empty in background (--background
command line argument) mode, which I'm interested in using.
I also tried from .__init__ import bl_info
but results were inconsistent across Blender versions and with/without background mode.
Upvotes: 0
Views: 733
Reputation: 184
Since importing __init__
caused issues for some reason, but importing other modules was fine, I made __init__
export the bl_info
version itself.
In __init__.py
:
def register():
util.addon_version = bl_info['version']
In util.py
:
def get_addon_version():
# this is set in __init__
return addon_version
Of course using util
as a name isn't mandatory, nor is using a get_addon_version()
getter function. I used a getter to make future changes easier.
Upvotes: 2