My plugin (https://github.com/jdc0589/JsFormat/tree/jsbeautifier_upgrade) has a dependency on the jsbeautifier project (https://github.com/einars/js-beautify/tree/master/python). Previously I was able to just copy a single file over from the jsbeautifier project, but they have re-organized the strucure of the jsbeautifier/python submodule. Something about how sublime sets the path up is preventing the ‘unpackers’ submodule of jsbeautifier from being imported (it cant find it).
the basic structure of my plugin and jsbeautifier is as follows:
JsFormat
> Default (Linux).sublime-keymap
> js_formatter.py
> jsbeautifier
>> __init__.py (not empty)
>> tests
>>> __init__.py
>> unpackers
>>> __init__.py (not empty)
js_formatter.py contains the sublime textcommand for my plugin, which imports and runs jsbeautifier. jsbeautifier/init.py attempts to ‘import jsbeautifier.unpackers’, which fails, and is the real problem. The import fails on jsbeautifier/init.py line 255. If I fire up a python repl from the root of the plugin directory importing jsbeautifier or jsbeautifier.unpackers works as expected.
I have tried changing the import logic of my plugin as follows, but it has not resolved the problem:
import sublime, sublime_plugin, re, sys, os
directory = os.path.dirname(os.path.realpath(__file__)) + "\\"
jsb_unpackers = directory+"\\jsbeautifier\\unpackers\\"
sys.path.append(jsb_unpackers)
import jsbeautifier
Any suggestions?