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

Importing rpm fails on openSUSE Leap from a virtualenv #9

Closed
1 of 2 tasks
dcermak opened this issue Jun 29, 2024 · 3 comments · Fixed by #11
Closed
1 of 2 tasks

Importing rpm fails on openSUSE Leap from a virtualenv #9

dcermak opened this issue Jun 29, 2024 · 3 comments · Fixed by #11
Labels
bug Something isn't working

Comments

@dcermak
Copy link

dcermak commented Jun 29, 2024

What happened? What is the problem?

The rpm module fails to initialize rpm in a virtualenvironment on openSUSE Leap with python 3.11. To reproduce:

$ podman run --pull=always --rm -it registry.opensuse.org/opensuse/leap:15.6
# zypper -n in python311 python311-pip python311-rpm
# cd home/
# python3.11 -m venv .env3
# source .env3/bin/activate
(.env3) # pip install rpm
Collecting rpm
  Downloading rpm-0.1.0-py3-none-any.whl.metadata (2.5 kB)
Downloading rpm-0.1.0-py3-none-any.whl (4.0 kB)
Installing collected packages: rpm
Successfully installed rpm-0.1.0

[notice] A new release of pip is available: 24.0 -> 24.1.1
[notice] To update, run: pip install --upgrade pip
(.env3) # python
Python 3.11.9 (main, Apr 15 2024, 10:36:26) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpm
Traceback (most recent call last):
  File "/home/.env3/lib64/python3.11/site-packages/rpm/__init__.py", line 102, in <module>
    _shim_module_initializing_
NameError: name '_shim_module_initializing_' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/.env3/lib64/python3.11/site-packages/rpm/__init__.py", line 105, in <module>
    initialize()
  File "/home/.env3/lib64/python3.11/site-packages/rpm/__init__.py", line 94, in initialize
    raise ImportError(
ImportError: Failed to import system RPM module. Make sure RPM Python bindings are installed on your system.
>>> 

What did you expect to happen?

The import to succeed

Example URL(s)

No response

Steps to reproduce

No response

Workaround

  • There is an existing workaround that can be used until this issue is fixed.

Participation

  • I am willing to submit a pull request for this issue. (Packit team is happy to help!)
@nforro nforro added the bug Something isn't working label Jul 1, 2024
@nforro nforro moved this from new to backlog in Packit Kanban Board Jul 1, 2024
@ricardobranco777
Copy link

Also hit by this issue but it seems to affect only the Leap 15.6 image and not a bare-metal installation.

@ktdreyer
Copy link

ktdreyer commented Aug 7, 2024

Looks similar to the problem I found on Red Hat's ubi9 with the python311 stack there: #10

@nforro
Copy link
Member

nforro commented Aug 12, 2024

Looks similar to the problem I found on Red Hat's ubi9 with the python311 stack there: #10

Yes, the fix for #10 will fix also this issue. Although the traceback would look similar even if it was a completely different issue 🙂

Also hit by this issue but it seems to affect only the Leap 15.6 image and not a bare-metal installation.

It depends on whether /usr/bin/python3 is present or not, in the image there is no Python and you install python311 which installs python311-base which provides /usr/bin/python3.11.

@nforro nforro moved this from backlog to in-progress in Packit Kanban Board Aug 12, 2024
@nforro nforro moved this from in-progress to in-review in Packit Kanban Board Aug 12, 2024
softwarefactory-project-zuul bot added a commit that referenced this issue Aug 12, 2024
Consider also majorver.minorver variant of Python interpreter

Fixes #9.
Fixes #10.
RELEASE NOTES BEGIN
rpm-shim now considers also system Python interpreter called python{majorver}.{minorver} when gathering the list of paths to try importing the system rpm module from. Peviously only python{majorver} and platform-python were considered.
RELEASE NOTES END

Reviewed-by: Maja Massarini
@github-project-automation github-project-automation bot moved this from in-review to done in Packit Kanban Board Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants