1
$\begingroup$

I have some functions that need to get the version of the addon to stamp in a custom property the version number it was run with.

Beyond that I do not know if it is a correct practice, I was wondering if it was possible to create a submodule with the bl_info (which I have already tried without any success), and call it when needed, or, to obtain in a submodule, the bl_info directly, contained in the __init__.py (i.e. the addon module)

into __init__.py:

bl_info = {
    "name": "My addon name",
    "author": "NoobCat",
    "version": (1, 0, 0)
    "blender": (2, 93, 0),
    "location": "",
    "description": "", 
    "tracker_url": "",      
    "category": ""}

Or my guess in a submodule, but it didn't work:

into utility.py:

def get_bl_info():

    bl_info = {
            "name": "My addon name",
            "author": "NoobCat",
            "version": (1, 0, 0)
            "blender": (2, 93, 0),
            "location": "",
            "description": "", 
            "tracker_url": "",      
            "category": ""}

    return bl_info

Now at the start into __init__.py

from . import utility

bl_info = utility.get_bl_info()

However, this does not seem to work

It seemed like a convenient idea to write bl_info in 1 place, and have access from any module easily. But I have recently been working with modules and am still very confused

$\endgroup$
1

1 Answer 1

4
$\begingroup$

bl_info is read out from __init__.py's AST (abstract syntax tree). IOW it has to be found just from parsing the code, without executing it. The code is only executed when the addon is enabled, but bl_info is needed even for disabled addons.

You can access bl_info defined at the top of __init__.py from utility.py with

from . import bl_info
$\endgroup$
1
  • $\begingroup$ I didn't know this, and it's really what I was looking for. $\endgroup$
    – Noob Cat
    Jun 18, 2021 at 10:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .