File: remove_pkg_resources.patch

package info (click to toggle)
python-py 1.11.0-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,512 kB
  • sloc: python: 11,660; makefile: 119; sh: 7
file content (22 lines) | stat: -rw-r--r-- 726 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
--- a/py/_vendored_packages/apipkg/__init__.py
+++ b/py/_vendored_packages/apipkg/__init__.py
@@ -27,15 +27,11 @@
 def distribution_version(name):
     """try to get the version of the named distribution,
     returs None on failure"""
-    from pkg_resources import get_distribution, DistributionNotFound
-
+    from importlib.metadata import PackageNotFoundError, version
     try:
-        dist = get_distribution(name)
-    except DistributionNotFound:
-        pass
-    else:
-        return dist.version
-
+        return version(name)
+    except PackageNotFoundError:
+        return None
 
 def initpkg(pkgname, exportdefs, attr=None, eager=False):
     """ initialize given package from the export definitions. """