This is an automated email from the ASF dual-hosted git repository.

juergbi pushed a commit to branch juerg/update-fixes
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit b9532f955a66634619389b4ec9289ce3c74504f4
Author: Jürg Billeter <[email protected]>
AuthorDate: Fri Jul 26 14:36:07 2024 +0200

    pluginoriginpip.py: Fix error type for setuptools 70
---
 src/buildstream/_pluginfactory/pluginoriginpip.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/buildstream/_pluginfactory/pluginoriginpip.py 
b/src/buildstream/_pluginfactory/pluginoriginpip.py
index a50534f60..d739abeb1 100644
--- a/src/buildstream/_pluginfactory/pluginoriginpip.py
+++ b/src/buildstream/_pluginfactory/pluginoriginpip.py
@@ -34,6 +34,13 @@ class PluginOriginPip(PluginOrigin):
 
         import pkg_resources
 
+        try:
+            # For setuptools >= 70
+            import packaging
+        except ImportError:
+            # For setuptools < 70
+            import pkg_resources.extern.packaging as packaging
+
         # Sources and elements are looked up in separate
         # entrypoint groups from the same package.
         #
@@ -66,7 +73,7 @@ class PluginOriginPip(PluginOrigin):
             # For setuptools < 49.0.0
             pkg_resources.RequirementParseError,
             # For setuptools >= 49.0.0
-            pkg_resources.extern.packaging.requirements.InvalidRequirement,
+            packaging.requirements.InvalidRequirement,
         ) as e:
             raise PluginError(
                 "{}: Malformed package-name '{}' encountered: {}".format(

Reply via email to