My scripts are available through the plugin manager.
I have a custom module that resides in the root of my script folder, in the folder jkGlyphsScripts. I can import from that module in my scripts that are in different subfolders locally without problem e.g.:
from jkGlyphsScripts.forSelected import forSelectedLayers
from jkGlyphsScripts.hintingPS.ocd import fix_hint_directions
forSelectedLayers(Glyphs.font, fix_hint_directions)
… but when the scripts are installed through the plugin manager, they are in a subfolder of Glyphs’ scripts folder, and the import doesn’t find the module anymore. Is there a solution to make this work?
Not tested in your case, but I use sth. like this to dynamically add the script’s location to the sys.path in a unit test script of mine. Maybe you could tweak it to make it work?
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from Foo.bar import MFFooBar as App # Foo is the folder, bar is the python file in there
Thanks! My concern with this method would be that the path would have to be added each time Glyphs was started?
I’ve solved this in a different way: I’ve moved the imported module to a separate GitHub repo, and set it as a dependency for my scripts in the plugin manager.
I saw code that would check the path several times already and it seems to be ok. Adding the module makes sense if there might like to use it, too, otherwise use relative imports or the sys.path.