Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stone CLI and importing custom helpers #10

Closed
diwakergupta opened this issue Jul 25, 2016 · 4 comments
Closed

Stone CLI and importing custom helpers #10

diwakergupta opened this issue Jul 25, 2016 · 4 comments

Comments

@diwakergupta
Copy link
Contributor

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
Copy link
Contributor

I assume go_helpers is only in your python path because it's in your current working directory?

@diwakergupta
Copy link
Contributor Author

@braincore correct

@braincore
Copy link
Contributor

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.

@braincore
Copy link
Contributor

@zjiuyang also ran into this so I fixed it in c7c5817.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants