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 4ef82cdba7e0666abf7bb686e3b39e0df2d01374 Author: Jürg Billeter <[email protected]> AuthorDate: Fri Jul 26 14:36:07 2024 +0200 pluginoriginpip.py: Fix error type for setuptools 70 --- setup.cfg | 2 +- src/buildstream/_pluginfactory/pluginoriginpip.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 7be278651..63cbbcbb4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -42,7 +42,7 @@ warn_no_return = True # Ignore missing stubs for third-party packages. # In future, these should be re-enabled if/when stubs for them become available. -[mypy-copyreg,grpc,pluginbase,psutil,pyroaring,ruamel,multiprocessing.forkserver] +[mypy-copyreg,grpc,pluginbase,psutil,pyroaring,ruamel,multiprocessing.forkserver,pkg_resources.extern] ignore_missing_imports=True # Ignore issues with generated files and vendored code diff --git a/src/buildstream/_pluginfactory/pluginoriginpip.py b/src/buildstream/_pluginfactory/pluginoriginpip.py index a50534f60..542776e0b 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 + from pkg_resources.extern import 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(
