-
-
Notifications
You must be signed in to change notification settings - Fork 782
Rescue Python path code #5142
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
Rescue Python path code #5142
Conversation
|
I created a StackStorm v3.3 stable on Ubuntu XenialStackStorm v3.3 stable on Ubuntu BionicStackStorm v3.4dev on Ubuntu Bionic (unfixed) |
d8a127e to
8188f25
Compare
8188f25 to
e8327f9
Compare
fa3ce02 to
74fb938
Compare
|
I would also hope that with getting rid of Python 2.7 we will be able to simplify that PYTHONPATH logic, but looks like that is sadly not the case :/ |
|
I believe there is the intention to encourage everyone to use python3 relative imports but we can't do that when we've not given anyone any warning! |
Kami
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, although for anything more I would need to dig in (I know that code had various edge cases, for which we did have tests, but yeah removing Python 2.7 support probably exposed some more).
|
@amanda11 Thanks for the additional context. I do hope that in the future, we will be able to simplify some of that code (although, based on this PR that would mean the change would likely not be fully backward compatible :/) |
|
Once we force packs to use explicit relative imports instead of implicit relative imports (this is a change made by Python 3 as well), we can simplify some of this a tiny bit. |
|
Closes #5127 as well. |
This PR partially reverts the code removed in #5100 and refactors it a bit since we no longer need to deal with Python 2.7 at all.
In StackStorm <= v3.3, when the sandboxing code was generating a
PYTHONPATHfor Python actions, it would prepend the operating system's Python directory (eg:/usr/lib/python3.5) in an attempt to provide modules and packages from the Python 3 stdlib before the third party packages (usually backports of the same name) for Python 2.7 (eg:<st2root>/st2/lib/python2.7/site-packages).All of that was over-enthusiastically ripped out when we removed Python 2.7 support, however some of the
PYTHONPATHhandling for Python actions is still necessary.With this PR, the code once again generates an appropriate
PYTHONPATHfor Python actions:libdirectory (eg:<st2root>/virtualenvs/<pack>/lib/python3.x)site-packagesdirectory (eg:<st2root>/virtualenvs/<pack>/lib/python3.x/site-packages)libdirectory (eg:<st2root>/packs/<pack>/actions/lib)PYTHONPATH, or from the parent virtualenv (the code is only ever called with both set toTrue), so StackStorm's systemsite-packagesdirectory will always be appended (eg:<st2root>/st2/lib/python3.x/site-packages)As we no longer support Python 2.7, we do not need to prepend the
PYTHONPATHwith the operating system's Python 3 path.I have also resurrected the tests for this function and refactored them as well.
This might also fix the Windows end-to-end tests that started to fail a few weeks ago.
Related issues and PRs:
Fixes #5126. Special thanks for @amanda11 for catching that before the v3.4 release!
This is currently a WIP. I still need to tweak the tests a bit.