Skip to contentSkip to conversation

bindings: python: relax the verbosity adjustment in build_tests.sh

PATCH Applied Bartosz Golaszewski 1 participant 2 messages Nov 27, 2024 – Dec 2, 2024 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bindings: python: relax the verbosity adjustment in build_tests.sh

From: Bartosz Golaszewski <[email protected]>

When building tests using the build_tests.py script, we try to increase the verbosity using setuptools.logging.configure() preferably but falling back to distutils.log.set_verbosity() if the former is missing.

This however creates a hard dependency on distutils on older environments missing the recently added setuptools method. The build however, can work fine even with default (low) verbosity so instead of bailing out if the second import fails, just keep going.

---
 bindings/python/build_tests.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
bindings/python/build_tests.py +6 -2
index 84cedfc..ebe1727 100644
@@ -82,9 +82,13 @@ try:
 
     configure()
 except ImportError:
-    from distutils.log import DEBUG, set_verbosity
+    try:
+        from distutils.log import DEBUG, set_verbosity
 
-    set_verbosity(DEBUG)
+        set_verbosity(DEBUG)
+    except ImportError:
+        # We can still build the tests, it will just be very quiet.
+        pass
 
 with tempfile.TemporaryDirectory(prefix="libgpiod-") as temp_dir:
     command = build_ext(dist)
Signature · 1 line
2.45.2
author Applied
#1 lore raw

From: Bartosz Golaszewski <[email protected]>

Quoted 10 lines · Bartosz Golaszewski

When building tests using the build_tests.py script, we try to increase the verbosity using setuptools.logging.configure() preferably but falling back to distutils.log.set_verbosity() if the former is missing.

This however creates a hard dependency on distutils on older environments missing the recently added setuptools method. The build however, can work fine even with default (low) verbosity so instead of bailing out if the second import fails, just keep going.

[...]

Applied, thanks!

[1/1] bindings: python: relax the verbosity adjustment in build_tests.sh

      commit: 27ec1af8b1836a1fcd6cbb8376324a21ee5b483e

Best regards,

Signature · 1 line
Bartosz Golaszewski <[email protected]>