Hi,
Im porting my plugin to ST3 and found that now my plugin does not get loaded during plugin initialization because it can find the required modules:
Traceback (most recent call last):
File “/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py”, line 73, in reload_plugin
m = importlib.import_module(modulename)
File “X/importlib/init.py”, line 88, in import_module
File “”, line 1577, in _gcd_import
File “”, line 1558, in _find_and_load
File “”, line 1525, in _find_and_load_unlocked
File “”, line 586, in _check_name_wrapper
File “”, line 1023, in load_module
File “”, line 1004, in load_module
File “”, line 562, in module_for_loader_wrapper
File “”, line 869, in _load_module
File “”, line 313, in _call_with_frames_removed
File “/Users/alvaro/Library/Application Support/Sublime Text 3/Packages/Rule Editor/unittests.py”, line 35, in
from whoosh.index import create_in
ImportError: No module named ‘whoosh’
Im loading Whoosh from my plugin directory like:
def add_to_path(path):
if os.name == ‘nt’:
buf = create_unicode_buffer(512)
if windll.kernel32.GetShortPathNameW(path, buf, len(buf)):
path = buf.value
if path not in sys.path:
sys.path.append(path)
common_lib_folder = os.path.join(sublime.packages_path(), ‘Rule Editor’, ‘lib’, ‘common’)
add_to_path(common_lib_folder)
from whoosh.index import create_in
from whoosh.fields import *
That used to work in ST2 but now is not working any longer. The thing is that if I open the plugin py file and save it (effectively reloading the plugin) the plugin just gets loaded correctly but not during initialization time.
The problem is that during initialization time, sublime.packages_path() is empty and after initialization it correctly points to the Packages folder.
Is this a bug in ST3 or is there any way to get the Packages folder during initialization time?
Thanks,
A