From 03d411c937b65a5c695791f00789a633baab39ce Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 19 Nov 2022 13:14:18 +0100 Subject: [PATCH] dist: Workaround to disable autodiscovery in setuptools>=61.0.0 See #1394 - creates a new finalize_distribution_options entry point that makes sure that either `py_modules` or `packages` is present, otherwise setuptools will activate its new auto-discovery system, even for custom commands that don't need setuptools' discovery system. However, this is not a great solution, because it applies when running all setuptools commands, not just build_apps. --- direct/src/dist/commands.py | 11 +++++++++++ makepanda/makepanda.py | 3 +++ makepanda/makewheel.py | 2 ++ 3 files changed, 16 insertions(+) diff --git a/direct/src/dist/commands.py b/direct/src/dist/commands.py index e55ed8a2cd..02e2285606 100644 --- a/direct/src/dist/commands.py +++ b/direct/src/dist/commands.py @@ -1685,3 +1685,14 @@ 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 = [] diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index e348702d7e..49d0d74283 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -3259,6 +3259,9 @@ Author-email: etc-panda3d@lists.andrew.cmu.edu ENTRY_POINTS = """[distutils.commands] build_apps = direct.dist.commands:build_apps bdist_apps = direct.dist.commands:bdist_apps + +[setuptools.finalize_distribution_options] +build_apps = direct.dist.commands:finalize_distribution_options """ if not PkgSkip("DIRECT"): diff --git a/makepanda/makewheel.py b/makepanda/makewheel.py index fbcace6b56..f7ab00a0f9 100644 --- a/makepanda/makewheel.py +++ b/makepanda/makewheel.py @@ -765,6 +765,8 @@ __version__ = '{0}' entry_points += '[distutils.commands]\n' entry_points += 'build_apps = direct.dist.commands:build_apps\n' entry_points += 'bdist_apps = direct.dist.commands:bdist_apps\n' + entry_points += '[setuptools.finalize_distribution_options]\n' + entry_points += 'build_apps = direct.dist.commands:finalize_distribution_options\n' whl.write_file_data('panda3d_tools/__init__.py', PANDA3D_TOOLS_INIT.format(tools_init))