Browse Source

dist: Remove panda3d dependency for global dist hook

Fixes #1624
rdb 1 year ago
parent
commit
1f41edd0a0
2 changed files with 17 additions and 11 deletions
  1. 16 0
      direct/src/dist/_dist_hooks.py
  2. 1 11
      direct/src/dist/commands.py

+ 16 - 0
direct/src/dist/_dist_hooks.py

@@ -0,0 +1,16 @@
+# This module should not import Panda3D modules globally as it contains hooks
+# that may be invoked by setuptools even when Panda3D is not used.  If the
+# Panda3D installation is broken, it should not affect other applications.
+
+__all__ = ('finalize_distribution_options', )
+
+
+def finalize_distribution_options(dist):
+    """Entry point for compatibility with setuptools>=61, see #1394."""
+
+    options = dist.get_option_dict('build_apps')
+    if options.get('gui_apps') or options.get('console_apps'):
+        # Make sure this is set to avoid auto-discovery taking place.
+        if getattr(dist.metadata, 'py_modules', None) is None and \
+           getattr(dist.metadata, 'packages', None) is None:
+            dist.py_modules = []

+ 1 - 11
direct/src/dist/commands.py

@@ -25,6 +25,7 @@ import distutils.log
 from . import FreezeTool
 from . import FreezeTool
 from . import pefile
 from . import pefile
 from .icon import Icon
 from .icon import Icon
+from ._dist_hooks import finalize_distribution_options
 import panda3d.core as p3d
 import panda3d.core as p3d
 
 
 
 
@@ -1765,14 +1766,3 @@ class bdist_apps(setuptools.Command):
 
 
                 else:
                 else:
                     self.announce('\tUnknown installer: {}'.format(installer), distutils.log.ERROR)
                     self.announce('\tUnknown installer: {}'.format(installer), distutils.log.ERROR)
-
-
-def finalize_distribution_options(dist):
-    """Entry point for compatibility with setuptools>=61, see #1394."""
-
-    options = dist.get_option_dict('build_apps')
-    if options.get('gui_apps') or options.get('console_apps'):
-        # Make sure this is set to avoid auto-discovery taking place.
-        if getattr(dist.metadata, 'py_modules', None) is None and \
-           getattr(dist.metadata, 'packages', None) is None:
-            dist.py_modules = []