Browse Source

ref: replace pkg_resources with importlib.metadata in sentry.debug (#61055)

<!-- Describe your PR here. -->
anthony sottile 1 year ago
parent
commit
b7b2cc5830
1 changed files with 6 additions and 9 deletions
  1. 6 9
      src/sentry/debug/utils/packages.py

+ 6 - 9
src/sentry/debug/utils/packages.py

@@ -1,19 +1,16 @@
+import importlib.metadata
 import sys
 
-import pkg_resources
-
 
 def get_package_version(module_name, app):
     version = None
 
-    # Try to pull version from pkg_resource first
+    # Try to pull version from importlib.metadata first
     # as it is able to detect version tagged with egg_info -b
-    if pkg_resources is not None:
-        # pull version from pkg_resources if distro exists
-        try:
-            return pkg_resources.get_distribution(module_name).version
-        except Exception:
-            pass
+    try:
+        return importlib.metadata.version(module_name)
+    except Exception:
+        pass
 
     if hasattr(app, "get_version"):
         version = app.get_version