Control: tags -1 - moreinfo
Control: close -1 0.17.0-2

On Fri, Oct 07, 2022 at 03:26:15PM +0200, Félix Sipma wrote:
> Hi,
> 
> Could you provide logs? python3-pkg-resources does not seem to be required
> to run khard on a minimal sid.

The problem is not in sid.

In bullseye I get:

$ khard 
Traceback (most recent call last):
  File "/usr/bin/khard", line 6, in <module>
    from pkg_resources import load_entry_point
ModuleNotFoundError: No module named 'pkg_resources'
$

> I don't get why it would be different for stable.

The attached diff of /usr/bin/khard shows how a no-change rebuild in 
bullseye fixes the issue.

> Regards,

cu
Adrian
--- khard-old   2022-10-15 11:47:22.284480615 +0300
+++ khard-new   2022-10-15 11:47:10.932481181 +0300
@@ -1,12 +1,33 @@
 #!/usr/bin/python3
 # EASY-INSTALL-ENTRY-SCRIPT: 'khard==0.17.0','console_scripts','khard'
-__requires__ = 'khard==0.17.0'
 import re
 import sys
-from pkg_resources import load_entry_point
+
+# for compatibility with easy_install; see #2198
+__requires__ = 'khard==0.17.0'
+
+try:
+    from importlib.metadata import distribution
+except ImportError:
+    try:
+        from importlib_metadata import distribution
+    except ImportError:
+        from pkg_resources import load_entry_point
+
+
+def importlib_load_entry_point(spec, group, name):
+    dist_name, _, _ = spec.partition('==')
+    matches = (
+        entry_point
+        for entry_point in distribution(dist_name).entry_points
+        if entry_point.group == group and entry_point.name == name
+    )
+    return next(matches).load()
+
+
+globals().setdefault('load_entry_point', importlib_load_entry_point)
+
 
 if __name__ == '__main__':
     sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
-    sys.exit(
-        load_entry_point('khard==0.17.0', 'console_scripts', 'khard')()
-    )
+    sys.exit(load_entry_point('khard==0.17.0', 'console_scripts', 'khard')())

Reply via email to