diff --git a/direct/src/dist/_dist_hooks.py b/direct/src/dist/_dist_hooks.py new file mode 100644 index 0000000000..a611c35dbc --- /dev/null +++ b/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 = [] diff --git a/direct/src/dist/commands.py b/direct/src/dist/commands.py index 9cc7ce455f..94ab191d0b 100644 --- a/direct/src/dist/commands.py +++ b/direct/src/dist/commands.py @@ -25,6 +25,7 @@ import distutils.log from . import FreezeTool from . import pefile from .icon import Icon +from ._dist_hooks import finalize_distribution_options import panda3d.core as p3d @@ -1765,14 +1766,3 @@ class bdist_apps(setuptools.Command): else: 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 = []