From b80740ed069cebe5a8dd56256400d62c9479e4b6 Mon Sep 17 00:00:00 2001 From: Rok Mandeljc Date: Wed, 7 Sep 2022 12:55:26 +0200 Subject: [PATCH] hooks: setuptools: avoid recursing into vendored pyparsing.diagram When collecting submodules from `setuptools._vendor`, avoid recursing into `setuptools._vendor.pyparsing.diagram`, which is usually unimportable and this generates a warning. --- PyInstaller/hooks/hook-setuptools.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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