I am having an issue initialising extensions on startup without getting errors. I have already implemented a workaround, which consists in force-reinit-ing all the extensions post-startup like so:
def SoftReset(self) -> None:
for shortcut in op:
if shortcut.isupper() and shortcut != 'UTILS':
run(f"op.{shortcut}.par.reinitextensions.pulse()")
This works but is not ideal because the toe file always open with errors that get cleared on reinit.
The issue:
My system requires both external python libraries (installed in a specific folder) and to access custom classes from another python file (stored in a separate folder). This means that I cannot simply use the “Preferences → Python 64-bit Module Path” because it accepts only a single path, and thus cannot accept both custom locations.
On startup, I do check for paths, and if they aren’t there, add them with the following method:
def AddDependenciesTopath(self) -> None:
dep_path = f'{project.folder}/../python/libraries'
norm_dep_path = os.path.normpath(dep_path)
if norm_dep_path not in sys.path:
sys.path.insert(0, norm_dep_path)
scripts_folder = f'{project.folder}/../globscripts'
norm_scripts_folder = os.path.normpath(scripts_folder)
if norm_scripts_folder not in sys.path:
sys.path.insert(0, norm_scripts_folder)
however this seems to run after the extensions tried to initialise and thus after all the errors have been thrown on the console. These errors, have all to do with libraries not being found:
ModuleNotFoundError:
Error retrieving extension for /SETTINGS: tdError: Module compilation error. See /SETTINGS/SettingsExt for details.
<string>, line 1, in <module>
Context:(Extension 1)
DAT compile error: /project/engine_1/EngExt
Traceback (most recent call last):
File "/project/engine_1/EngExt", line 1
r = previousimport(*args, **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'tdtypes'
Error retrieving extension for /project/engine_1: tdError: Module compilation error. See /project/engine_1/EngExt for details.
<string>, line 1, in <module>
Context:(Extension 1)
DAT compile error: /project/engine_1/template1/VidExt
Traceback (most recent call last):
File "/project/engine_1/template1/VidExt", line 2
r = previousimport(*args, **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'tdtypes'
This is also particularly weird because all my extensions are set to not reinit on start, so they should be able to remain dormant until the startup procedure has completed and thus the paths are present. I am sure I am doing it wrong, but I’ve tried multiple things and nothing works.
If the only way to solve this is to install the libraries at system level, and add environment variables, I will resort to that, but I would prefer not to.