From 36bcfe77050457f7d44648be283100f60fe7a377 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 15 Oct 2023 13:47:08 +0200 Subject: [PATCH] dist: Switch build_apps from pkg_resources to importlib.metadata --- direct/src/dist/commands.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/direct/src/dist/commands.py b/direct/src/dist/commands.py index 9ee83736cf..1caef566fb 100644 --- a/direct/src/dist/commands.py +++ b/direct/src/dist/commands.py @@ -54,10 +54,16 @@ def _register_python_loaders(): _register_python_loaders.done = True - registry = p3d.LoaderFileTypeRegistry.getGlobalPtr() + from importlib.metadata import entry_points - import pkg_resources - for entry_point in pkg_resources.iter_entry_points('panda3d.loaders'): + eps = entry_points() + if isinstance(eps, dict): # Python 3.8 and 3.9 + loaders = eps.get('panda3d.loaders', ()) + else: + loaders = eps.select(group='panda3d.loaders') + + registry = p3d.LoaderFileTypeRegistry.get_global_ptr() + for entry_point in loaders: registry.register_deferred_type(entry_point) @@ -1698,7 +1704,7 @@ class bdist_apps(setuptools.Command): setattr(self, opt, None) def finalize_options(self): - import pkg_resources + from importlib.metadata import entry_points # We need to massage the inputs a bit in case they came from a # setup.cfg file. @@ -1712,11 +1718,17 @@ class bdist_apps(setuptools.Command): self.signing_certificate = os.path.abspath(self.signing_certificate) self.signing_private_key = os.path.abspath(self.signing_private_key) + eps = entry_points() + if isinstance(eps, dict): # Python 3.8 and 3.9 + installer_eps = eps.get('panda3d.bdist_apps.installers', ()) + else: + installer_eps = eps.select(group='panda3d.bdist_apps.installers') + tmp = self.DEFAULT_INSTALLER_FUNCS.copy() tmp.update(self.installer_functions) tmp.update({ entrypoint.name: entrypoint.load() - for entrypoint in pkg_resources.iter_entry_points('panda3d.bdist_apps.installers') + for entrypoint in installer_eps }) self.installer_functions = tmp