-
Notifications
You must be signed in to change notification settings - Fork 148
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
Python3-keystone (OpenStack identity service) conflicts with keystone-engine when installed. #276
Comments
I don't think there's much we can do if 2 different libraries use the same name, it's pretty much out of our control. I did look into this though and it seems that it might be a Debian issue? I'm saying this because on my distro Arch, You might have to look into why it loads the system ones instead of venv as it should be the other way around to my knowledge. |
I've also double checked and, on Arch, they use the same name as the packages for the directories (assembler uses Checking the .deb file it seems that they place it in the keystone folder instead of keystoneauth1. You should flag a bug with the package maintainer or anybody else that handles the package naming in Debian. Though your best bet is to find out why venv is being ignored as I doubt they would change anything about this. |
I sent a bug-report to debian about the python3-virtualenv module rather than about the python3-keystone package -- packages should always be loaded from the virtual environment and never from the system unless a named-package does not exist. I'm currently waiting for the bug-report number and confirmation of its receipt. |
We're using |
I'll have to wait for the bug confirmation against python3-virtualenv -- at which point I can request it to be removed and open a new one against python3-venv. |
Make sure to double check that venv was used instead of virtualenv, just so we're on the same page. You did use our installer for PINCE instead of manually installing stuff right? Also as a side note, while you wait for the bug to be fixed, I highly recommend using our AppImage instead of dealing with the dev install if you simply want to just use PINCE. The installer is reserved for developers and code contributors, not for general use. |
I used the installer script and I had both virtualenv and venv installed, but removing virtualenv did not make a difference as far as keystone being loaded from the system instead of the virtual path. |
Try the AppImage then to see if the If that also does not work, then you're at the mercy of Debian maintainers, so good luck. Let us know when that bug gets closed/resolved so we can also close this one. |
Using the appimage, while python3-keystone (openstack) is installed, did not report errors about not being able to import the namespace Ks . The bug opened against python3-venv (python3-defaults/3.11.2-1) can be found here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1091740 PS: |
Here's an update from the Debian bug Report #1091740 Editing and running PINCE.sh so it only runs the python interpeter and does not execute PINCE.py I get the following:
This means that original error message (about noting being able to import name 'Ks' from 'keystone' ) is strictly an issue with PINCE -- the package is trying to be loaded from /usr/lib/python3/dist-packages/keystone:
PS: This failing behavior could happen if the system python is executed by some process instead of the python binary from the virtual environment. |
Try manually running |
EDIT: My suspicions were correct -- the system path list, in the context of sourcing gdbextensions, will not load packages from the virtual environment because it is looking in the system path first.
I think this issue is the result of the gdbextensions.py being sent as a source command to gdb. https://github.com/korcankaraokcu/PINCE/blob/master/libpince/debugcore.py#L521 def set_pince_paths():
"""Initializes $PINCE_PATH and $GDBINIT_AA_PATH convenience variables to make commands in gdbextensions.py
and gdbutils.py work. GDB scripts need to know libpince and .config directories, unfortunately they don't start
from the place where script exists
"""
libpince_dir = utils.get_libpince_directory()
pince_dir = os.path.dirname(libpince_dir)
gdbinit_aa_dir = utils.get_user_path(typedefs.USER_PATHS.GDBINIT_AA)
send_command("set $GDBINIT_AA_PATH=" + '"' + gdbinit_aa_dir + '"')
send_command("set $PINCE_PATH=" + '"' + pince_dir + '"')
send_command("source gdb_python_scripts/gdbextensions.py") I think when gdb sources this file it running in a context outside of the virtual environment and that's why it attempts to load keystone from /usr/lib/python3/dist-packages. It doesn't look like the gdbextensions even uses the keystone functionality, it only seems to call some other utility functions, ie that file may not need to import the keystone package. I'm still investigation this issue...I will see if I can get the gdbextensions.py to report the path for the keystone library and the system path, to try to confirm my suspicions stated above. |
That has nothing to do with your problem. We already make the gdb spawned inside PINCE respect the venv environment by importing a specific Your problem is that the venv environment itself is not getting activated. This creates a snowball effect where you run into the issues you listed but they're not the main cause. You modified Manually run the commands inside
Something broke in Debian's behaviour of including the venv and I have a hunch it's the preserve-env (which was added as a hack for Debian/Ubuntu only anyway) that broke. |
I see the virtual env path listed in the output and both have the same path list. $ . .venv/PINCE/bin/activate
$ .venv/PINCE/bin/python3
Python 3.11.2 (main, Nov 30 2024, 21:22:50) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
[
'',
'/usr/lib/python311.zip',
'/usr/lib/python3.11',
'/usr/lib/python3.11/lib-dynload',
'/home/william/Apps/Emulators/pince/.venv/PINCE/lib/python3.11/site-packages'
]
>>>quit()
$ . .venv/PINCE/bin/activate
$ sudo -E --preserve-env=PATH .venv/PINCE/bin/python3
Python 3.11.2 (main, Nov 30 2024, 21:22:50) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
[
'',
'/usr/lib/python311.zip',
'/usr/lib/python3.11',
'/usr/lib/python3.11/lib-dynload',
'/home/william/Apps/Emulators/pince/.venv/PINCE/lib/python3.11/site-packages'
]
>>>quit() PS: I can create a minimal venv the keystone package isloaded correctly (as per the Debian Bug I opened): $ python3 -m venv testvenv
$ . ./testvenv/bin/activate
$ ./testvenv/bin/python -m pip install -U keystone-engine
$ sudo -E --preserve-env=PATH ./testvenv/bin/python
Python 3.11.2 (main, Nov 30 2024, 21:22:50) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import keystone
>>> keystone.__file__
'/media/PNY64GB/debian-bug-1091740/testvenv/lib/python3.11/site-packages/keystone/__init__.py'
>>> import sys
>>> sys.path
[
'',
'/usr/lib/python311.zip',
'/usr/lib/python3.11',
'/usr/lib/python3.11/lib-dynload',
'/media/PNY64GB/debian-bug-1091740/testvenv/lib/python3.11/site-packages'
] |
Hmm, do me a favour and modify Inside it we extend the sys path of gdb's Python with the one we have from the venv environment. Instead of extending it, just replace sys.path with the |
I think that was the problem. After I changing it to
It is no longer complaining about importing the namespaces from the keystone package. |
That's also why it only happens on Debian as Debian is pretty much the only one from our supported list that names the OpenStack one I'll look into it tomorrow or just after new years to make sure changing that doesn't break our other distros or AppImage. Feel free to use the AppImage meanwhile until we commit the fix. Thanks for testing. |
Fixed with 9327a7a Thanks for the report! |
When the package Python3-keystone is installed on Debian (see https://packages.debian.org/sid/python3-keystone) pince will fail to import the keystone-engine related functions because the two packages have the same name and python seems to favor loading from /usr/lib/python3/dist-package instead of from the virtual environment. Without the Python3-keystone package installed, pince operates as expected.
I don't know if there is a way to force python to never load packages that exist outside of the virtual environment (or to prevent certain packages from being loaded from the system path) -- I mean other than explicitly importing the module from the VIRTUAL_ENV path.
Here's the error that occurs right after the program starts -- additionally, trying to attach to a process will cause pince to hang.
The text was updated successfully, but these errors were encountered: