My add-on needs to run both inside and outside of Blender (I have unit tests that I run with a headless version of Blender to make sure everything continues to work).
How do I determine in my __init__.py
file if my package is being loaded and ran in Blender versus being loaded in just normal Python?
What I've tried:
globals()
does not seem to contain anything useful to check at least in a loaded Python file. It has quite a few things in the Python console as well as when running a file from the TextEditor in Blender.sys.modules[__name__].__addon_enabled__
does not seem to worktry: import bpy
work for my case as I have a module in my environment calledbpy
(headless Blender)
sys.argv
? $\endgroup$