I am developing in Python/Blender, and have two needs here:
Currently I am doing this (in __init__.py
):
from importlib import reload
from .MyPlugin import *
reload(MyPlugin)
classes = [ClassA, ClassB, ClassC]
# register each class, not shown here
However the reload(MyPlugin)
line causes an error: "MyPlugin is not defined".
Originally I tried reloading each of the classes instead, but it raised an error that reload
expects a module.
Some colleagues helped me with an answer, what ended up working was this in __init__.py
:
from importlib import reload
if "MyModule" in locals():
reload(MyModule)
else:
import MyModule
from .MyModule import *
This is detailed here: https://blenderartists.org/t/how-to-reload-add-on-code/1202715/2