From 5fa0be491ea66ce24156e27c4e932a0452d667ce Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 29 Nov 2024 10:09:36 +1100 Subject: [PATCH] Extensions: suppress noisy prints for extension wheel filtering These messages could flood the output even when extension installation succeeded. Only show them when Python debugging is enabled. --- .../addons_core/bl_pkg/bl_extension_ops.py | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/scripts/addons_core/bl_pkg/bl_extension_ops.py b/scripts/addons_core/bl_pkg/bl_extension_ops.py index 6dcfea02b80..89df64b907e 100644 --- a/scripts/addons_core/bl_pkg/bl_extension_ops.py +++ b/scripts/addons_core/bl_pkg/bl_extension_ops.py @@ -945,6 +945,12 @@ def _extensions_wheel_filter_for_this_system(wheels): # it's highly doubtful users ever run into this but we could add extend this if it's really needed. # (e.g. `linux-i686` on 64 bit systems & `linux-armv7l`). import sysconfig + + # When false, suppress printing for incompatible wheels. + # This generally isn't a problem as it's common for an extension to include wheels for multiple platforms. + # Printing is mainly useful when installation fails because none of the wheels are compatible. + debug = bpy.app.debug_python + platform_tag_current = sysconfig.get_platform().replace("-", "_") import sys @@ -999,12 +1005,12 @@ def _extensions_wheel_filter_for_this_system(wheels): ): pass else: - # Useful to know, can quiet print in the future. - print( - "Skipping wheel for other system", - "({:s} != {:s}):".format(platform_tag, platform_tag_current), - wheel_filename, - ) + if debug: + print( + "Skipping wheel for other system", + "({:s} != {:s}):".format(platform_tag, platform_tag_current), + wheel_filename, + ) continue # Perform Python Version Checks. @@ -1038,17 +1044,17 @@ def _extensions_wheel_filter_for_this_system(wheels): break if not python_version_is_compat: - # Useful to know, can quiet print in the future. - print( - "Skipping wheel for other Python version", - "({:s}=>({:s}) not in {:d}.{:d}):".format( - python_tag, - ", ".join([".".join(str(i) for i in v) for v in python_versions]), - python_version_current[0], - python_version_current[1], - ), - wheel_filename, - ) + if debug: + print( + "Skipping wheel for other Python version", + "({:s}=>({:s}) not in {:d}.{:d}):".format( + python_tag, + ", ".join([".".join(str(i) for i in v) for v in python_versions]), + python_version_current[0], + python_version_current[1], + ), + wheel_filename, + ) continue wheels_compatible.append(wheel)