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

Append /usr/local/lib to sys.path if import fails #1027

Merged
merged 5 commits into from
Jan 5, 2025

Conversation

sezanzeb
Copy link
Owner

No description provided.

@sezanzeb
Copy link
Owner Author

@skitt am I doing something bad with this change? Maybe there is a good reason why sys.path is not containing /usr/local/lib/python3.12/dist-packages when udev triggers the script.

@skitt
Copy link
Contributor

skitt commented Dec 30, 2024

I don’t think you’re doing anything bad, that directory should be in sys.path:

$ python3
Python 3.12.8 (main, Dec 13 2024, 13:19:48) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/usr/lib/python312.zip', '/usr/lib/python3.12', '/usr/lib/python3.12/lib-dynload', '/usr/local/lib/python3.12/dist-packages', '/usr/lib/python3/dist-packages']

I haven’t checked whether udev is doing anything special.

@sezanzeb
Copy link
Owner Author

Thanks a lot for looking at this. Yeah, in udev it is different:

udev:

Dez 30 13:43:30 proxima (udev-worker)[57992]: (...) '['/usr/bin', '/lib/python312.zip', '/lib/python3.12', '/lib/python3.12/lib-dynload', '/lib/python3/dist-packages']'

sudo:

➜  ~ sudo python3 -c "import sys; print(sys.path)"
['', '/usr/lib/python312.zip', '/usr/lib/python3.12', '/usr/lib/python3.12/lib-dynload', '/usr/local/lib/python3.12/dist-packages', '/mnt/data/Code/input-remapper-2', '/usr/local/lib/python3.12/dist-packages/evdev-1.7.1-py3.12-linux-x86_64.egg', '/usr/lib/python3/dist-packages']

as user:

➜  ~ python3 -c "import sys; print(sys.path)"
['', '/usr/lib/python312.zip', '/usr/lib/python3.12', '/usr/lib/python3.12/lib-dynload', '/home/mango/.local/lib/python3.12/site-packages', '/mnt/data/Code/music-library-sync', '/usr/local/lib/python3.12/dist-packages', '/mnt/data/Code/input-remapper-2', '/usr/local/lib/python3.12/dist-packages/evdev-1.7.1-py3.12-linux-x86_64.egg', '/usr/lib/python3/dist-packages']

@sezanzeb sezanzeb marked this pull request as ready for review January 1, 2025 21:44
@sezanzeb sezanzeb merged commit f859e91 into main Jan 5, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants