View Single Post
Old 09-02-2017, 02:54 PM   #227
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,751
Karma: 206739468
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by KevinH View Post
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')

Last edited by DiapDealer; 09-02-2017 at 02:57 PM.
DiapDealer is offline   Reply With Quote