Skip to content
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

CPythonInvoker: fix python path by inserting custom path before default path #23244

Merged
merged 1 commit into from
May 10, 2023

Conversation

lrusak
Copy link
Contributor

@lrusak lrusak commented May 7, 2023

This fixes #22985 reported by @matthuisman

#21704 changed the way the python path order was handled. It put the custom python path after the default python path. This causes an issue where custom python modules are used for a specific add-on and the same module was installed on the system python path. The system python path would be ordered before the custom python path.

This PR inserts the custom python path at the beginning of the python path instead of the end.

I also made a minor change to the way the paths are logged. I'm not sure if that is desired or not.

Before:

2023-05-06 21:00:12.613 T:520144   debug <general>: CPythonInvoker(2): default python path:
2023-05-06 21:00:12.613 T:520144   debug <general>: CPythonInvoker(2):   /usr/lib64/python311.zip
2023-05-06 21:00:12.613 T:520144   debug <general>: CPythonInvoker(2):   /usr/lib64/python3.11
2023-05-06 21:00:12.613 T:520144   debug <general>: CPythonInvoker(2):   /usr/lib64/python3.11/lib-dynload
2023-05-06 21:00:12.613 T:520144   debug <general>: CPythonInvoker(2):   /usr/local/lib/python3.11/site-packages
2023-05-06 21:00:12.613 T:520144   debug <general>: CPythonInvoker(2):   /usr/lib64/python3.11/site-packages
2023-05-06 21:00:12.614 T:520144   debug <general>: CPythonInvoker(2):   /usr/lib/python3.11/site-packages
2023-05-06 21:00:12.614 T:520144   debug <general>: CPythonInvoker(2): adding path:
2023-05-06 21:00:12.614 T:520144   debug <general>: CPythonInvoker(2):  /home/lukas/.kodi/addons/plugin.video.youtube/resources/lib
2023-05-06 21:00:12.614 T:520144   debug <general>: CPythonInvoker(2):  /home/lukas/.kodi/addons/script.module.certifi/lib
2023-05-06 21:00:12.614 T:520144   debug <general>: CPythonInvoker(2):  /home/lukas/.kodi/addons/script.module.chardet/lib
2023-05-06 21:00:12.614 T:520144   debug <general>: CPythonInvoker(2):  /home/lukas/.kodi/addons/script.module.idna/lib
2023-05-06 21:00:12.614 T:520144   debug <general>: CPythonInvoker(2):  /home/lukas/.kodi/addons/script.module.infotagger/resources/modules
2023-05-06 21:00:12.614 T:520144   debug <general>: CPythonInvoker(2):  /home/lukas/.kodi/addons/script.module.inputstreamhelper/lib
2023-05-06 21:00:12.614 T:520144   debug <general>: CPythonInvoker(2):  /home/lukas/.kodi/addons/script.module.pysocks/lib
2023-05-06 21:00:12.614 T:520144   debug <general>: CPythonInvoker(2):  /home/lukas/.kodi/addons/script.module.requests/lib
2023-05-06 21:00:12.614 T:520144   debug <general>: CPythonInvoker(2):  /home/lukas/.kodi/addons/script.module.urllib3/lib

After:

2023-05-06 20:52:26.126 T:517352   debug <general>: CPythonInvoker(2): full python path:
2023-05-06 20:52:26.126 T:517352   debug <general>: CPythonInvoker(2):   custom python path:
2023-05-06 20:52:26.126 T:517352   debug <general>: CPythonInvoker(2):     /home/lukas/.kodi/addons/plugin.video.youtube/resources/lib
2023-05-06 20:52:26.126 T:517352   debug <general>: CPythonInvoker(2):     /home/lukas/.kodi/addons/script.module.certifi/lib
2023-05-06 20:52:26.126 T:517352   debug <general>: CPythonInvoker(2):     /home/lukas/.kodi/addons/script.module.chardet/lib
2023-05-06 20:52:26.126 T:517352   debug <general>: CPythonInvoker(2):     /home/lukas/.kodi/addons/script.module.idna/lib
2023-05-06 20:52:26.126 T:517352   debug <general>: CPythonInvoker(2):     /home/lukas/.kodi/addons/script.module.infotagger/resources/modules
2023-05-06 20:52:26.126 T:517352   debug <general>: CPythonInvoker(2):     /home/lukas/.kodi/addons/script.module.inputstreamhelper/lib
2023-05-06 20:52:26.126 T:517352   debug <general>: CPythonInvoker(2):     /home/lukas/.kodi/addons/script.module.pysocks/lib
2023-05-06 20:52:26.126 T:517352   debug <general>: CPythonInvoker(2):     /home/lukas/.kodi/addons/script.module.requests/lib
2023-05-06 20:52:26.126 T:517352   debug <general>: CPythonInvoker(2):     /home/lukas/.kodi/addons/script.module.urllib3/lib
2023-05-06 20:52:26.126 T:517352   debug <general>: CPythonInvoker(2):   default python path:
2023-05-06 20:52:26.126 T:517352   debug <general>: CPythonInvoker(2):     /usr/lib64/python311.zip
2023-05-06 20:52:26.126 T:517352   debug <general>: CPythonInvoker(2):     /usr/lib64/python3.11
2023-05-06 20:52:26.126 T:517352   debug <general>: CPythonInvoker(2):     /usr/lib64/python3.11/lib-dynload
2023-05-06 20:52:26.126 T:517352   debug <general>: CPythonInvoker(2):     /usr/local/lib/python3.11/site-packages
2023-05-06 20:52:26.126 T:517352   debug <general>: CPythonInvoker(2):     /usr/lib64/python3.11/site-packages
2023-05-06 20:52:26.126 T:517352   debug <general>: CPythonInvoker(2):     /usr/lib/python3.11/site-packages

The diff looks messy and is better viewed in the split view -> link

What is the effect on users?

allows add-ons to work properly by allowing custom python modules to be preferred.

…lt path

Signed-off-by: Lukas Rusak <lorusak@gmail.com>
@lrusak lrusak added Type: Fix non-breaking change which fixes an issue Component: Python v21 Omega labels May 7, 2023
@lrusak lrusak added this to the Omega 21.0 Alpha 2 milestone May 7, 2023
@jenkins4kodi
Copy link
Contributor

I've made some formatting changes to meet the current code style. The diffs are available in the following links:

For more information please see our current code style guidelines.

@fuzzard fuzzard merged commit f911f34 into xbmc:master May 10, 2023
2 checks passed
@matthuisman
Copy link
Contributor

matthuisman commented May 11, 2023

@lrusak do you think this should be backported to nexus? I've worked around this issue anyway but might be good to have it fixed in next nexus?

I can prepare that PR if it makes things easier

@lrusak
Copy link
Contributor Author

lrusak commented May 11, 2023

@lrusak do you think this should be backported to nexus? I've worked around this issue anyway but might be good to have it fixed in next nexus?

I can prepare that PR if it makes things easier

Yes, and I can do it ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backport: Done Component: Python Type: Fix non-breaking change which fixes an issue v21 Omega
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kodi 20 Regression: Python sys.path in-correct (site-packages before addon / dependencies)
4 participants