Skip to content

Conversation

@Kami
Copy link
Member

@Kami Kami commented May 8, 2019

This pull request fixes a bug which would cause some packs to break when running Python 3 actions on installations where StackStorm components run under Python 2.

Background, Context

Some pack dependencies or action code depend on packages / modules which are available in Python 3 standard library, but they are also available in Python 2 site-packages directory (usually as an installable backport).

We didn't correctly add base Python 3 library directory (e.g. /usr/lib/python3.6) to PYTHONPATH for such actions so things broke because it tried to use incompatible package / module from Python 2 instead from Python 3.

This pull request fixes that.

TODO

  • End to end tests (I will add a test pack which contains an action which relies on such package)

Resolves #4658.

Kami added 3 commits May 8, 2019 21:13
/usr/lib/python3.6) not being in the PYTHONPATH for Python actions which
used --python3 flag.

This meant some packs which rely on 3rd party packages / modules which
are available as part of Python 3 standard library and also Python 2
site-packages were incorrectly loaded from Python 2 site-packages
instead of Python 3 standard library.
@Kami Kami added this to the 3.0.1 milestone May 8, 2019
# one
# NOTE: abc.py is always available in base lib directory which is symlinked to virtualenv
# lib directory
abc_module_path = os.path.join(python3_lib_directory, 'abc.py')
Copy link
Member Author

@Kami Kami May 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too happy about this approach, but from the research I did, I couldn't come up with a better one.

I will also look into it more when adding end to end tests and testing it under various Python 3 versions on all the supported versions to verify it indeed covers all the scenarios and works correctly on all the platforms.

@Kami Kami requested a review from blag May 10, 2019 10:15
Copy link
Contributor

@blag blag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@oatsgithub
Copy link

We're still experiencing the same issue with StackStorm HA. We have 4 internal packs and 2 of them are failing because StackStorm tries to execute their actions in Python 2 (we don't have any Python 2 code).

requirements.txt:

hvac
python-consul
requests

All our packs have these libraries but only 2 of them try to run in Python 2.

@Kami
Copy link
Member Author

Kami commented Oct 7, 2019

@oatsgithub Please open a new issue for that and include all the relevant information we need to be able to reproduce the issue (StackStorm versions, packs and actions in question, action runner debug level logs, etc.).

@blag
Copy link
Contributor

blag commented May 15, 2020

This is a great candidate for a bigfix release of v3.1.

@blag blag mentioned this pull request Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

st2 python3 interpreter is falling back to importing a python2 lib that is incompatible with python3

4 participants