-
-
Notifications
You must be signed in to change notification settings - Fork 762
Idea to fix issue #5310 - Using site packages of a different python version for actionrunner #5388
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
base: master
Are you sure you want to change the base?
Changes from all commits
559bbcc
546f5c2
58877d3
5ba4afb
4e282ba
3d5591a
043958a
bab39f8
3da886c
a7fb408
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,26 @@ def get_sandbox_python_path_for_python_action( | |
|
||
pack_base_path = get_pack_base_path(pack_name=pack) | ||
virtualenv_path = get_sandbox_virtualenv_path(pack=pack) | ||
python_binary = cfg.CONF.actionrunner.python_binary | ||
|
||
# Add the custom python's site-packages directory in front of the Python | ||
# system site-packages if python_binary is not default. | ||
if python_binary is not sys.executable and os.path.isfile(python_binary): | ||
python_version = python_binary.rsplit("/", 1)[1] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you give me an example of how this is supposed to work? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @cognifloyd, as mentioned in the title already this is an idea and I am open for better solutions. I just created it based on what I currently see on my system and found on the internet about python and site packages. If someone just sets What I have seen so far is that site-packages are usually located at: That is the reason why I created The idea behind these lines was to fix the issue without additional config options as a user might think it should work out of the box when he sets the If you want to catch all possibilities, it might be better to implement a new config option like Third possibility would be to use both. Look for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yes. I like this implementation and how it avoids additional config options. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of hard-coding the list of site-packages dirs, what if you looked for the dir relative to the |
||
system_prefix_dirs = ["/usr/lib", "/usr/local/lib"] | ||
system_dir_names = ["site-packages", "dist-packages"] | ||
for system_prefix_dir in system_prefix_dirs: | ||
for system_dir_name in system_dir_names: | ||
if os.path.isdir( | ||
os.path.join(system_prefix_dir, python_version, system_dir_name) | ||
): | ||
custom_py_site_pack_dir = os.path.join( | ||
system_prefix_dir, python_version, system_dir_name | ||
) | ||
existing_sandbox_py_path = sandbox_python_path | ||
sandbox_python_path = ( | ||
f"{custom_py_site_pack_dir}:{existing_sandbox_py_path}" | ||
) | ||
|
||
if virtualenv_path and os.path.isdir(virtualenv_path): | ||
pack_virtualenv_lib_path = os.path.join(virtualenv_path, "lib") | ||
|
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.
OK. I see that this is already defined. I'll just leave this note here for the next time I review this so I don't have to look it up again.
st2/st2common/st2common/config.py
Lines 454 to 458 in f5c0c0f