Quote:
Originally Posted by KevinH
Diapdealer - is there any way to figure out where the python3lib is located in the current launcher or wrapper plugin code given what we pass in the sigil.cfg file?
|
Not really from that cfg info, no.
And there's not a completely straightforward other way considering how many different ways Sigil can be installed on Linux, I should probably add Sigil's support file root location (typically /usr/share/sigil or /usr/local/share/sigil) to PluginRunner's cfg file that gets parsed by wrapper.py. But until that happens, Sigil's support file root location could be literally anywhere. It can be changed at compile-time or runtime.
However ... I believe the "plugin_launchers/python" directory is already added to every plugin's sys.path. If that can be identified, the python3lib directory is always going to be ../../python3lib from that one.
Something in here should get someone going in the meantime.
Code:
import sys, os
for path in sys.path:
if "plugin_launchers/python" in path:
print(path)
sys.path.append(os.path.join(path, '../../python3lib'))
print(sys.path)
break
try:
import ncxgenerator
print('python3lib path', os.path.dirname(os.path.abspath(ncxgenerator.__file__)))
except ImportError:
print('Can\'t find python3lib')