You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# make sverchok the root module name, (if sverchok dir not named exactly "sverchok")
if__name__!="sverchok":
sys.modules["sverchok"] =sys.modules[__name__]
the same modules can be imported several times. This is bad because some modules can share information between eachother via third modules and if each of them has its own instance of a module then there is no information interchange. In general I think all modules should have only one instance.
Looks like that sverchok name was added to sys.modules so that import path could be started from sverchok name. But it's not clear why relative import paths could not be used instead.
Adding main module reachable by sverchok name makes importing modules peculiar. For example:
…4281
Settings were purposely imported via addon_folder_name.settings instead of sverchok.settings. I assume this was done to be able to write this: class SvPreferences: bl_idname = __package__. Because it seems that bl_idname of add-on settings should always be equal to name of add-on folder.
Problem statement
Because of this code
sverchok/core/__init__.py
Lines 96 to 99 in a5d0742
sverchok/__init__.py
Lines 64 to 66 in a5d0742
the same modules can be imported several times. This is bad because some modules can share information between eachother via third modules and if each of them has its own instance of a module then there is no information interchange. In general I think all modules should have only one instance.
Looks like that
sverchok
name was added tosys.modules
so that import path could be started from sverchok name. But it's not clear why relative import paths could not be used instead.Adding main module reachable by sverchok name makes importing modules peculiar. For example:
I'm not sure yet how this can be handled. Probably adding
__name__ = "sverchok"
would solve the problem.Useful links:
https://b3d.interplanety.org/en/creating-multifile-add-on-for-blender/
https://devtalk.blender.org/t/plugin-hot-reload-by-cleaning-sys-modules/20040
The text was updated successfully, but these errors were encountered: