From 73b3197da49d052cc29a256f79d34c21c704d02c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marina=20A=C3=ADsa?= Date: Mon, 28 Jul 2025 18:47:06 +0100 Subject: [PATCH 1/3] Make build-script-helper.py use python3 By aiming to update the Node version to 22.17.0 on Swift Docker for Swift DocC Render [1], we need to specify the version 3 of python, otherwise it will try to use python 2 which it's not available in Node 22. [1] https://github.com/swiftlang/swift-docker/pull/487 --- build-script-helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-script-helper.py b/build-script-helper.py index 1a8800d41..1128529a4 100755 --- a/build-script-helper.py +++ b/build-script-helper.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ This source file is part of the Swift.org open source project From 9a78e548b9191e624def1090aa6c88c90ba445ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marina=20A=C3=ADsa?= Date: Mon, 28 Jul 2025 19:19:11 +0100 Subject: [PATCH 2/3] Removed Python 2 compatibility import Removed from __future__ import print_function on line 16, which is not needed in Python 3 since print() is already a function by default. --- build-script-helper.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/build-script-helper.py b/build-script-helper.py index 1128529a4..2da89cdd1 100755 --- a/build-script-helper.py +++ b/build-script-helper.py @@ -13,8 +13,6 @@ knows how to build and install the swift-docc-render. """ -from __future__ import print_function - import argparse import os import platform From e39cb6f740fa28cdbf83a507049fa1c9a1bda799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marina=20A=C3=ADsa?= Date: Mon, 28 Jul 2025 19:19:43 +0100 Subject: [PATCH 3/3] Fixed subprocess output handling Updated the node version check to properly handle the fact that subprocess.check_output() returns bytes in Python 3, not strings. Added code to decode bytes to UTF-8 string and strip whitespace before checking the version. --- build-script-helper.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build-script-helper.py b/build-script-helper.py index 2da89cdd1..5129772f6 100755 --- a/build-script-helper.py +++ b/build-script-helper.py @@ -73,7 +73,10 @@ def ensure_npm_is_installed(verbose=False): fatal_error('-- Error: %s' % error_msg) try: node_version = check_output(['node', '--version'], verbose=verbose) - if not node_version.startswith('v18.16.'): + # Ensure node_version is a string (decode if it's bytes) + if isinstance(node_version, bytes): + node_version = node_version.decode('utf-8') + if not node_version.strip().startswith('v18.16.'): warn_msg = "Unexpected version of 'node' installed. Swift-DocC-Render requires node 18.16.1. "\ "See the README.md file for more information about building Swift-DocC-Render." printerr('-- Warning: %s' % warn_msg)