importing bl_info from another file in __init__ breaks the addon importing #53617

Closed
opened 2017-12-23 11:39:43 +01:00 by Walid Shouman · 6 comments
Member

System Information
Linux

Blender Version
Broken: 2.79 7b397cdfc81

Short description of error

  • Is the limitation of having bl_info filed only at the init.py intended.
    In example: it's not possible to restructure the addon script so that we can import the bl_info from another info.py file (an example is attached)
    init.py

info.py

  • Is it intended that, reopening the same blender file that the script importing failed at gives the same error and breaks the addon tab, and one should remove the addon manually from the scripts directory?
    blender_addon_broken.png

Exact steps for others to reproduce the error
importing any addon with an imported bl_info instead of hardcoded

Appendix
Error message

AST error parsing bl_info for console_scripts
Traceback (most recent call last):
  File "/home/walid/Desktop/blender-2.79-rc2-linux-glibc219-x86_64/2.79/scripts/modules/addon_utils.py", line 137, in fake_module
    mod.bl_info = ast.literal_eval(body.value)
  File "/home/walid/Desktop/blender-2.79-rc2-linux-glibc219-x86_64/2.79/python/lib/python3.5/ast.py", line 84, in literal_eval
    return _convert(node_or_string)
  File "/home/walid/Desktop/blender-2.79-rc2-linux-glibc219-x86_64/2.79/python/lib/python3.5/ast.py", line 83, in _convert
    raise ValueError('malformed node or string: ' + repr(node))
ValueError: malformed node or string: <_ast.Call object at 0x7f80426fe4a8>
Traceback (most recent call last):
  File "/home/walid/Desktop/blender-2.79-rc2-linux-glibc219-x86_64/2.79/scripts/startup/bl_ui/space_userpref.py", line 1372, in draw
    addons = [(mod, addon_utils.module_bl_info(mod)) for mod in addon_utils.modules(refresh=False)]
  File "/home/walid/Desktop/blender-2.79-rc2-linux-glibc219-x86_64/2.79/scripts/modules/addon_utils.py", line 199, in modules
    modules_refresh(module_cache)
  File "/home/walid/Desktop/blender-2.79-rc2-linux-glibc219-x86_64/2.79/scripts/modules/addon_utils.py", line 187, in modules_refresh
    force_support=force_support)
  File "/home/walid/Desktop/blender-2.79-rc2-linux-glibc219-x86_64/2.79/scripts/modules/addon_utils.py", line 137, in fake_module
    mod.bl_info = ast.literal_eval(body.value)
  File "/home/walid/Desktop/blender-2.79-rc2-linux-glibc219-x86_64/2.79/python/lib/python3.5/ast.py", line 84, in literal_eval
    return _convert(node_or_string)
  File "/home/walid/Desktop/blender-2.79-rc2-linux-glibc219-x86_64/2.79/python/lib/python3.5/ast.py", line 83, in _convert
    raise ValueError('malformed node or string: ' + repr(node))
ValueError: malformed node or string: <_ast.Call object at 0x7f80426fe4a8>
**System Information** Linux **Blender Version** Broken: 2.79 7b397cdfc81 **Short description of error** - Is the limitation of having bl_info filed only at the __init__.py intended. In example: it's not possible to restructure the addon script so that we can import the bl_info from another __info__.py file (an example is attached) [__init__.py](https://archive.blender.org/developer/F1501832/__init__.py) [__info__.py](https://archive.blender.org/developer/F1501831/__info__.py) - Is it intended that, reopening the same blender file that the script importing failed at gives the same error and breaks the addon tab, and one should remove the addon manually from the scripts directory? ![blender_addon_broken.png](https://archive.blender.org/developer/F1501842/blender_addon_broken.png) **Exact steps for others to reproduce the error** importing any addon with an imported bl_info instead of hardcoded **Appendix** Error message ``` AST error parsing bl_info for console_scripts Traceback (most recent call last): File "/home/walid/Desktop/blender-2.79-rc2-linux-glibc219-x86_64/2.79/scripts/modules/addon_utils.py", line 137, in fake_module mod.bl_info = ast.literal_eval(body.value) File "/home/walid/Desktop/blender-2.79-rc2-linux-glibc219-x86_64/2.79/python/lib/python3.5/ast.py", line 84, in literal_eval return _convert(node_or_string) File "/home/walid/Desktop/blender-2.79-rc2-linux-glibc219-x86_64/2.79/python/lib/python3.5/ast.py", line 83, in _convert raise ValueError('malformed node or string: ' + repr(node)) ValueError: malformed node or string: <_ast.Call object at 0x7f80426fe4a8> Traceback (most recent call last): File "/home/walid/Desktop/blender-2.79-rc2-linux-glibc219-x86_64/2.79/scripts/startup/bl_ui/space_userpref.py", line 1372, in draw addons = [(mod, addon_utils.module_bl_info(mod)) for mod in addon_utils.modules(refresh=False)] File "/home/walid/Desktop/blender-2.79-rc2-linux-glibc219-x86_64/2.79/scripts/modules/addon_utils.py", line 199, in modules modules_refresh(module_cache) File "/home/walid/Desktop/blender-2.79-rc2-linux-glibc219-x86_64/2.79/scripts/modules/addon_utils.py", line 187, in modules_refresh force_support=force_support) File "/home/walid/Desktop/blender-2.79-rc2-linux-glibc219-x86_64/2.79/scripts/modules/addon_utils.py", line 137, in fake_module mod.bl_info = ast.literal_eval(body.value) File "/home/walid/Desktop/blender-2.79-rc2-linux-glibc219-x86_64/2.79/python/lib/python3.5/ast.py", line 84, in literal_eval return _convert(node_or_string) File "/home/walid/Desktop/blender-2.79-rc2-linux-glibc219-x86_64/2.79/python/lib/python3.5/ast.py", line 83, in _convert raise ValueError('malformed node or string: ' + repr(node)) ValueError: malformed node or string: <_ast.Call object at 0x7f80426fe4a8> ```
Author
Member

Added subscriber: @WalidShouman

Added subscriber: @WalidShouman

blender/blender#81961 was marked as duplicate of this issue

blender/blender#81961 was marked as duplicate of this issue

Added subscriber: @ideasman42

Added subscriber: @ideasman42

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Campbell Barton self-assigned this 2018-01-02 09:29:25 +01:00

This is working as expected, bl_info must be declared in the module.

This is because bl_info is extracted without executing code.

This is working as expected, `bl_info` must be declared in the module. This is because `bl_info` is extracted without executing code.

Added subscriber: @randum

Added subscriber: @randum
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#53617
No description provided.