Browse Source

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.
rdb 3 years ago
parent
commit
03d411c937
3 changed files with 16 additions and 0 deletions
  1. 11 0
      direct/src/dist/commands.py
  2. 3 0
      makepanda/makepanda.py
  3. 2 0
      makepanda/makewheel.py

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

@@ -1685,3 +1685,14 @@ 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 = []

+ 3 - 0
makepanda/makepanda.py

@@ -3259,6 +3259,9 @@ Author-email: [email protected]
 ENTRY_POINTS = """[distutils.commands]
 ENTRY_POINTS = """[distutils.commands]
 build_apps = direct.dist.commands:build_apps
 build_apps = direct.dist.commands:build_apps
 bdist_apps = direct.dist.commands:bdist_apps
 bdist_apps = direct.dist.commands:bdist_apps
+
+[setuptools.finalize_distribution_options]
+build_apps = direct.dist.commands:finalize_distribution_options
 """
 """
 
 
 if not PkgSkip("DIRECT"):
 if not PkgSkip("DIRECT"):

+ 2 - 0
makepanda/makewheel.py

@@ -765,6 +765,8 @@ __version__ = '{0}'
     entry_points += '[distutils.commands]\n'
     entry_points += '[distutils.commands]\n'
     entry_points += 'build_apps = direct.dist.commands:build_apps\n'
     entry_points += 'build_apps = direct.dist.commands:build_apps\n'
     entry_points += 'bdist_apps = direct.dist.commands:bdist_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))
     whl.write_file_data('panda3d_tools/__init__.py', PANDA3D_TOOLS_INIT.format(tools_init))