[Pkg-libvirt-maintainers] Bug#1116124: virt-manager scripts use #!/usr/bin/env python shebang
John Pierce
john at killTERM.com
Wed Sep 24 03:45:43 BST 2025
Package: virt-manager
Version: 1:5.0.0-5
Severity: normal
Tags: patch
X-Debbugs-Cc: john at killTERM.com
I'm testing Ansible collections with a Molecule scenario that creates
libvirt managed KVM VMs. In order to test against the most recent
versions of Python, Ansible, Molecule, and the collection plugins I
create virtualenvs using pyenv managed Python installations.
The community.libvirt.virt_install module invokes the system
virt-install convenience script. When the pyenv / virtualenv managed
python is active, the virt-install script uses it instead of the system
python resulting in the error below.
Traceback (most recent call last):
File "/usr/bin/virt-install", line 6, in <module>
from virtinst import virtinstall
File "/usr/share/virt-manager/virtinst/__init__.py", line 50, in <module>
from virtinst.domain import * # pylint: disable=wildcard-import
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/share/virt-manager/virtinst/domain/__init__.py", line 5, in <module>
from .blkiotune import DomainBlkiotune
File "/usr/share/virt-manager/virtinst/domain/blkiotune.py", line 8, in <module>
from ..xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
File "/usr/share/virt-manager/virtinst/xmlbuilder.py", line 16, in <module>
from .xmlapi import XMLAPI
File "/usr/share/virt-manager/virtinst/xmlapi.py", line 7, in <module>
import libxml2
ModuleNotFoundError: No module named 'libxml2'
The Debian Python Policy specifically recommends using the full path to
the system python for this reason.
https://www.debian.org/doc/packaging-manuals/python-policy/#interpreter-location
-- System Information:
Debian Release: 13.1
APT prefers stable-security
APT policy: (990, 'stable-security'), (990, 'stable'), (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 6.12.21-hibernate (SMP w/16 CPU threads; PREEMPT)
Kernel taint flags: TAINT_WARN
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages virt-manager depends on:
ii dconf-gsettings-backend [gsettings-backend] 0.40.0-5
ii gir1.2-gtk-3.0 3.24.49-3
ii gir1.2-gtk-vnc-2.0 1.5.0-1
ii gir1.2-gtksource-4 4.8.4-6
ii gir1.2-libosinfo-1.0 1.12.0-2
ii gir1.2-libvirt-glib-1.0 5.0.0-2+b4
ii gir1.2-vte-2.91 0.80.1-1
ii python3 3.13.5-1
ii python3-gi 3.50.0-4+b1
ii python3-gi-cairo 3.50.0-4+b1
ii python3-libvirt 11.3.0-1
ii virt-install 1:5.0.0-5
Versions of packages virt-manager recommends:
ii gir1.2-ayatanaappindicator3-0.1 0.5.94-1
ii gir1.2-spiceclientglib-2.0 0.42-3
ii gir1.2-spiceclientgtk-3.0 0.42-3
ii libvirt-daemon-system 11.3.0-3
Versions of packages virt-manager suggests:
ii gir1.2-secret-1 0.21.7-1
ii gnome-keyring 48.0-1
pn python3-guestfs <none>
pn ssh-askpass <none>
pn virt-viewer <none>
Versions of packages virt-manager is related to:
ii libvirt-clients 11.3.0-3
ii libvirt-daemon 11.3.0-3
ii libvirt0 11.3.0-3
ii osinfo-db 0.20250606-1
-- no debconf information
-------------- next part --------------
From: John Pierce <john at killTERM.com>
Date: Tue, 23 Sep 2025 20:47:24 -0500
Subject: d/patches: use system python for shebang paths
Debian Python Policy (sections 3.5.2 and 5.1) depreciate /usr/bin/env
python in favor of /usr/bin/python3 for Python 3 scripts.
This policy ensures that the included convenience scripts have their
requisite dependencies met by the system package manager. This is
necessary when a user's PATH contains a non-system python, eg. pyenv,
virtualenv, etc.
---
scripts/make_bin_wrapper.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/make_bin_wrapper.py b/scripts/make_bin_wrapper.py
index 10de492..f5c1823 100644
--- a/scripts/make_bin_wrapper.py
+++ b/scripts/make_bin_wrapper.py
@@ -10,7 +10,7 @@ parser.add_argument("filename")
args = parser.parse_args()
print(
- f"""#!/usr/bin/env python3
+ f"""#!/usr/bin/python3
import sys
sys.path.insert(0, "{args.sharepath}")
More information about the Pkg-libvirt-maintainers
mailing list