[FEATURE] Add a Python 3 runner and pack wide virtualenv option
All of our dev effort into APIs, integrations and automation is going on Python 3.
It would be unreasonable to request StackStorm be upgraded to Python 2 so instead I'd like the option to use Python 3 packages and actions within my own packs. That is,
- Add a
python3runner to compliment thepythonrunner - Add the ability to configure in a pack which Python version is used with the virtualenv is created for the pack directory.
❤️
Not a bad request. We had a recent debate on it too for just general pack support. One of the problems is OS support for the python version. (We still support el6 for instance). I'm curious what the wrapper would need to be 2/3 compliant. Let us get 2.2 out and I'll put some cycles towards investigating this.
Yeah, from a high-level this sounds quite reasonable to me.
There are some edge cases (not all packages work with Python 3, etc.) but users who opt-in to use Python 3 would probably already be aware of that and we will still default to Python 2.
+1
I wonder if this is something we can do use the pluggable runners framework? Initially write a separate runner that people can install if they wish, which will use python3. Have to figure out all the virtualenv bits, but might be a way to start distributing an experimental runner?
I’m very interested in seeing this and/or testing it.
Hi, Is there any update on this ? Or is there a workaround/hack to use python3 for an extension ?
@etz69 as a workaround, you could have a shell-script action that launches a python3 script. But it won't be able to inherit from the ST2 Action class, or use pack config within the Python code, only in the parameters.
@LindsayHill It worked fine. I packed in one directory under actions all the files (python 3 virtualenv, source etc..) and just called via bash by sourcing the right env and just passing the arguments. Thanks !
Good to hear that it worked. It’s not ideal, and I would love to have a proper Python3 runner. But at least it gets you going
Hello guys,
+1 for this feature, is there any update on it?
With more and more libraries having Python 3 support (e.g. NAPALM for network automation), it is a bit disappointing to be stuck with Python 2 on StackStorm. The workaround can play well exceptionally, but if one is willing to completely switch to Python 3 (which probably makes sense for new developments with a perspective of multiple years of lifetime), then it is a bit of a showstopper...
+1 for this feature, is there any update on it?
No current plans or work in progress to implement this, but PRs are welcome.
If anyone does start working on this, then their PR would be linked to this issue, and you would be able to track that PR.
I’m going to start a WIP PR
Python implementation raised. Remaining tasks:
- [ ] tools/st2-setup-tests is a command-line script to setup the virtual env of a pack with the requirements. it is hard-coded to Python 2.7. This means all pack tests will run as Python 2.x
- [x] documentation needs to be updated
- [ ] Update CI for packs (https://github.com/stackstorm-exchange/ci) to read pack metadata and use correct Python version and pass correct flags to other scripts (run pack tests, etc.) if
system.python3attribute is True
Added a thing to your TODO - "Update CI for packs (https://github.com/stackstorm-exchange/ci) to read pack metadata and use correct Python version and pass correct flags to other scripts (run pack tests, etc.) if system.python3 attribute is True"
Docs update in PR https://github.com/StackStorm/st2docs/pull/677
@Kami The system attribute is simply of type "object" from what I saw.
@Kami The system attribute is simply of type "object" from what I saw.
Correct, but you can specify a schema and additional allowed keys / properties for an object. We haven't done that yet, because we didn't have an actual use case for that field yet, but now we do.
Something like this should work:
...
'system': {
'type': 'object',
'description': 'Specification for the system components and packages '
'required for the pack.',
'default': {}
'properties': {
'python3': {
'type': 'boolean',
'description': '....',
'default': False
}
},
'additionalProperties': True
}
....
Python 3 action support added into 2.8dev https://github.com/StackStorm/st2/pull/4149