From fc1ae1c8ab6c0e6375c28174db11f4b89fd40613 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 15 Jan 2025 09:34:32 -0800 Subject: [PATCH] Update min python version from 3.6 to 3.8 The reason for picking 3.8 here is that it provides all the features we currently have need of, and it available in the places we care about: - debian/stable (bookworm): 3.11 - ubuntu/LTS (focal): 3.8 - emsdk: 3.9.2 Replaces: #23378 Fixes: #23387 --- ChangeLog.md | 2 ++ tools/building.py | 13 +------------ tools/shared.py | 6 +++--- tools/system_libs.py | 11 +---------- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index bd1cc78513d09..f4407ff42c602 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -23,6 +23,8 @@ See docs/process.md for more on how version tagging works. - The minimum version of node required to run emscripten was bumped from v16.20 to v18. Version 4.0 was mistakenly shipped with a change that required v20, but that was reverted. (#23410) +- The version of python required to run emscripten was bumped from 3.6 to 3.8. + (#23417) 4.0.0 - 01/14/25 ---------------- diff --git a/tools/building.py b/tools/building.py index 3d764fe82d33a..231b810ce4c60 100644 --- a/tools/building.py +++ b/tools/building.py @@ -476,17 +476,6 @@ def check_closure_compiler(cmd, args, env, allowed_to_fail): return True -# Remove this once we require python3.7 and can use std.isascii. -# See: https://docs.python.org/3/library/stdtypes.html#str.isascii -def isascii(s): - try: - s.encode('ascii') - except UnicodeEncodeError: - return False - else: - return True - - def get_closure_compiler_and_env(user_args): env = shared.env_with_node_in_path() closure_cmd = get_closure_compiler() @@ -623,7 +612,7 @@ def run_closure_cmd(cmd, filename, env): tempfiles = shared.get_temp_files() def move_to_safe_7bit_ascii_filename(filename): - if isascii(filename): + if filename.isascii(): return os.path.abspath(filename) safe_filename = tempfiles.get('.js').name # Safe 7-bit filename shutil.copyfile(filename, safe_filename) diff --git a/tools/shared.py b/tools/shared.py index 1f4f37f24b5b0..d41af7466ba24 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -20,9 +20,9 @@ import sys import tempfile -# We depend on python 3.6 for fstring support -if sys.version_info < (3, 6): - print('error: emscripten requires python 3.6 or above', file=sys.stderr) +# We depend on python 3.8 features +if sys.version_info < (3, 8): + print(f'error: emscripten requires python 3.8 or above ({sys.executable} {sys.version})', file=sys.stderr) sys.exit(1) from . import colored_logger diff --git a/tools/system_libs.py b/tools/system_libs.py index ea06d88515a74..eac05f20e041c 100644 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -2442,17 +2442,8 @@ def calculate(args): return ret -# Once we require python 3.8 we can use shutil.copytree with -# dirs_exist_ok=True and remove this function. def copytree_exist_ok(src, dst): - os.makedirs(dst, exist_ok=True) - for entry in os.scandir(src): - srcname = os.path.join(src, entry.name) - dstname = os.path.join(dst, entry.name) - if entry.is_dir(): - copytree_exist_ok(srcname, dstname) - else: - shared.safe_copy(srcname, dstname) + shutil.copytree(src, dst, dirs_exist_ok=True) def install_system_headers(stamp):