Stone CLI and importing custom helpers
diwakergupta opened this issue · 4 comments
diwakergupta commented
I'm splitting the Go SDK generator into a types generator and a client generator. To do this, I've introduced a go_helpers
module. But I'm having trouble using the helper when invoking the stone
helper script. Specifically, this does not work:
$ stone -a :all -v "go_client.stoneg.py" "$gen_dir" "$spec_dir"/*.stone
...
error: Importing generator 'go_client.stoneg.py' module raised an exception:
Traceback (most recent call last):
File "/usr/local/bin/stone", line 9, in <module>
load_entry_point('stone==0.1', 'console_scripts', 'stone')()
File "/usr/local/lib/python3.5/site-packages/stone-0.1-py3.5.egg/stone/cli.py", line 303, in main
generator_module = imp.load_source('user_generator', args.generator)
File "/usr/local/Cellar/python3/3.5.2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/imp.py", line 172, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 693, in _load
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "go_client.stoneg.py", line 1, in <module>
from go_helpers import HEADER
ImportError: No module named 'go_helpers'
But this does:
$ python3 -m stone.cli -v go_client.stoneg.py /tmp dropbox-api-spec/*.stone
...
INFO:stone.compiler:Running generator: GoTypesGenerator
braincore commented
I assume go_helpers
is only in your python path because it's in your current working directory?
diwakergupta commented
@braincore correct
braincore commented
I'm actually not sure what to do here. The root cause is that the python path is different when called via the entry point vs. invoking python directly. The recommendation is for the entire generator to be in a single module when it isn't built-in to stone.