If you’re developing custom Python actions and use a
lib directory in
actions, you may have seen that all imports related to
lib start with
from lib.<submodule> import <something> or
a) your IDE is likely to report this import statement as invalid.
b) (afaik) you can’t test the code outside of StackStorm.
The proposed solution:
- add a
setup.pyfile to the
actionsdirectory with the following content:
from setuptools import setup, find_packages setup( name='lib', packages=find_packages('.'), )
- add this file to
- open a terminal (if you haven’t already ) and go into the
- run either
pip install -e ./or
python setup.py develop
- ATTENTION: if you’re deducing your
pip freeze, exclude the line corresponding to
lib(it’s a line starting with
-e, and containing a reference to the git repo)
- maybe restart the IDE if the IDE still reports the
libimport statements as wrong
lib imports should “work”, and also your IDE’s autocomplete/inspection features. Furthermore, you can now test your library code with ease
If you’re wondering what this was all about, check out Python Packaging. It’s straightforward and powerful.
Feedback, questions and comments on this procedure are very welcome.