diff --git a/PyInstaller/hooks/hook-setuptools.py b/PyInstaller/hooks/hook-setuptools.py index 55cc7c3ccf..21365dda1e 100644 --- a/PyInstaller/hooks/hook-setuptools.py +++ b/PyInstaller/hooks/hook-setuptools.py @@ -25,7 +25,13 @@ # setuptools >= 39.0.0 is "vendoring" its own direct dependencies from "_vendor" to "extern". This also requires # 'pre_safe_import_module/hook-setuptools.extern.six.moves.py' to make the moves defined in 'setuptools._vendor.six' # importable under 'setuptools.extern.six'. -hiddenimports.extend(collect_submodules('setuptools._vendor')) +_excluded_submodules = ( + # Prevent recursing into setuptools._vendor.pyparsing.diagram, which typically fails to be imported due to + # missing dependencies (railroad, pyparsing (?), jinja2) and generates a warning... As the module is usually + # unimportable, it is likely not to be used by setuptools. + 'setuptools._vendor.pyparsing.diagram', +) +hiddenimports.extend(collect_submodules('setuptools._vendor', filter=lambda name: name not in _excluded_submodules)) # As of setuptools >= 60.0, we need to collect the vendored version of distutils via hiddenimports. The corresponding # pyi_rth_setuptools runtime hook ensures that the _distutils_hack is installed at the program startup, which allows