Skip to content

Commit 28d35a8

Browse files
authored
Update min python version to 3.10 (#25891)
This also involved updating the base linux image on which we run our tests from Ubuntu/Focal 20.04 to Ubuntu/Jammy 22.04. This gives us access to match/case constructs, as well as for other nice things like `str.removeprefix`, and `BooleanOptionalArgument`.
1 parent 66dcf64 commit 28d35a8

34 files changed

+374
-386
lines changed

.circleci/config.yml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ executors:
1313
- image: cimg/python:3.10.7
1414
environment:
1515
EMCC_CORES: "4"
16-
focal:
16+
ubuntu-lts:
1717
docker:
18-
- image: emscripten/emscripten-ci:focal
18+
- image: emscripten/emscripten-ci:jammy
1919
environment:
2020
LANG: "C.UTF-8"
2121
EMCC_CORES: "4"
@@ -530,7 +530,7 @@ commands:
530530

531531
jobs:
532532
build-docs:
533-
executor: focal
533+
executor: ubuntu-lts
534534
steps:
535535
- checkout
536536
- pip-install
@@ -540,21 +540,21 @@ jobs:
540540
- run: make -C site html
541541
ruff:
542542
# Keep in sync with ruff commands in tools/maint/pre-push
543-
executor: focal
543+
executor: ubuntu-lts
544544
steps:
545545
- checkout
546546
- pip-install
547547
- run: ruff check
548548
# TODO (cclauss): When ruff supports rules these errors without --preview, remove following line
549549
- run: ruff check --preview --select=E20,E30,E221,E225,E226
550550
vulture:
551-
executor: focal
551+
executor: ubuntu-lts
552552
steps:
553553
- checkout
554554
- pip-install
555555
- run: vulture . --min-confidence 100
556556
mypy:
557-
executor: focal
557+
executor: ubuntu-lts
558558
steps:
559559
- checkout
560560
- pip-install
@@ -568,13 +568,13 @@ jobs:
568568
npm run lint
569569
npm run check
570570
test-sanity:
571-
executor: focal
571+
executor: ubuntu-lts
572572
steps:
573573
- run-tests-linux:
574574
frozen_cache: false
575575
test_targets: "sanity"
576576
build-linux:
577-
executor: focal
577+
executor: ubuntu-lts
578578
# xlarge has 4x the cores of the default medium, costs 4x as much, and runs
579579
# in about 1/2 the time, so it is not cost-effective (overall it is 2x the
580580
# cost for the same work), but given this blocks almost all the other jobs
@@ -632,19 +632,19 @@ jobs:
632632
- persist
633633
# Perhaps we don't need to run this suite with every commit. Consider moving this to FYI bot.
634634
test-posixtest:
635-
executor: focal
635+
executor: ubuntu-lts
636636
steps:
637637
- run-tests-linux:
638638
test_targets: "posixtest"
639639
test-core0:
640-
executor: focal
640+
executor: ubuntu-lts
641641
environment:
642642
EMTEST_SKIP_NODE_CANARY: "1"
643643
steps:
644644
- run-tests-linux:
645645
test_targets: "core0"
646646
test-core2:
647-
executor: focal
647+
executor: ubuntu-lts
648648
environment:
649649
EMTEST_BROWSER: "node"
650650
EMTEST_SKIP_NODE_CANARY: "1"
@@ -692,7 +692,7 @@ jobs:
692692
corez.test_dylink_syslibs_all"
693693
- upload-test-results
694694
test-core3:
695-
executor: focal
695+
executor: ubuntu-lts
696696
environment:
697697
EMTEST_SKIP_NODE_CANARY: "1"
698698
steps:
@@ -779,14 +779,14 @@ jobs:
779779
strict.test_dylink_global_inits_reversed
780780
"
781781
test-modularize-instance:
782-
executor: focal
782+
executor: ubuntu-lts
783783
environment:
784784
EMTEST_SKIP_NODE_CANARY: "1"
785785
steps:
786786
- run-tests-linux:
787787
test_targets: "instance"
788788
test-stress:
789-
executor: focal
789+
executor: ubuntu-lts
790790
environment:
791791
EMTEST_SKIP_NODE_CANARY: "1"
792792
steps:
@@ -810,7 +810,7 @@ jobs:
810810
test-wasm2js1:
811811
environment:
812812
EMTEST_SKIP_NODE_CANARY: "1"
813-
executor: focal
813+
executor: ubuntu-lts
814814
steps:
815815
- run-tests-linux:
816816
test_targets: "wasm2js1"
@@ -1062,7 +1062,7 @@ jobs:
10621062
"
10631063
- upload-test-results
10641064
test-other:
1065-
executor: focal
1065+
executor: ubuntu-lts
10661066
environment:
10671067
EMTEST_SKIP_NODE_CANARY: "1"
10681068
EMTEST_SKIP_RUST: "1"
@@ -1076,7 +1076,7 @@ jobs:
10761076
# headers on emsdk-bundled clang
10771077
test_targets: "other jslib skip:other.test_native_link_error_message"
10781078
test-browser-chrome:
1079-
executor: focal
1079+
executor: ubuntu-lts
10801080
environment:
10811081
EMTEST_LACKS_WEBGPU: "1"
10821082
steps:
@@ -1101,7 +1101,7 @@ jobs:
11011101
browser.test_audio_worklet*
11021102
"
11031103
test-browser-chrome-wasm64:
1104-
executor: focal
1104+
executor: ubuntu-lts
11051105
environment:
11061106
EMTEST_LACKS_WEBGPU: "1"
11071107
EMTEST_VISUALIZE: "1"
@@ -1131,23 +1131,23 @@ jobs:
11311131
name: Check profile
11321132
command: file -E out/graph.html
11331133
test-browser-chrome-2gb:
1134-
executor: focal
1134+
executor: ubuntu-lts
11351135
environment:
11361136
EMTEST_LACKS_WEBGPU: "1"
11371137
steps:
11381138
- run-tests-chrome:
11391139
title: "browser_2gb"
11401140
test_targets: "browser_2gb"
11411141
test-browser-chrome-wasm64-4gb:
1142-
executor: focal
1142+
executor: ubuntu-lts
11431143
environment:
11441144
EMTEST_LACKS_WEBGPU: "1"
11451145
steps:
11461146
- run-tests-chrome:
11471147
title: "browser64_4gb"
11481148
test_targets: "browser64_4gb"
11491149
test-browser-firefox:
1150-
executor: focal
1150+
executor: ubuntu-lts
11511151
environment:
11521152
EMTEST_LACKS_GROWABLE_ARRAYBUFFERS: "1"
11531153
steps:
@@ -1166,7 +1166,7 @@ jobs:
11661166
skip:browser.test_glut_glutget
11671167
"
11681168
test-browser-firefox-wasm64:
1169-
executor: focal
1169+
executor: ubuntu-lts
11701170
steps:
11711171
- checkout
11721172
- pip-install
@@ -1218,12 +1218,12 @@ jobs:
12181218
# TODO(sbc): Re-enable once we figure out why the emrun tests are
12191219
# locking up.
12201220
#test-browser-chrome-emrun:
1221-
# executor: focal
1221+
# executor: ubuntu-lts
12221222
# steps:
12231223
# - run-tests-chrome:
12241224
# test_targets: "emrun"
12251225
test-sockets-chrome:
1226-
executor: focal
1226+
executor: ubuntu-lts
12271227
steps:
12281228
- test-sockets-chrome
12291229

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ See docs/process.md for more on how version tagging works.
2020

2121
4.0.22 (in development)
2222
-----------------------
23+
- The minimum version of python required to run emscripten was updated from 3.8
24+
to 3.10. (#25891)
2325

2426
4.0.21 - 12/02/25
2527
-----------------

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[project]
2-
requires-python = ">=3.8"
2+
requires-python = ">=3.10"
33

44
[tool.ruff]
55
line-length = 100

test/common.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from functools import wraps
2323
from pathlib import Path
2424
from subprocess import PIPE, STDOUT
25-
from typing import Dict, Tuple
2625

2726
import clang_native
2827
import jsrun
@@ -1091,7 +1090,7 @@ def assertBinaryEqual(self, file1, file2):
10911090
self.assertEqual(read_binary(file1),
10921091
read_binary(file2))
10931092

1094-
library_cache: Dict[str, Tuple[str, object]] = {}
1093+
library_cache: dict[str, tuple[str, object]] = {}
10951094

10961095
def get_build_dir(self):
10971096
ret = self.in_dir('building')

test/other/ports/external.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# found in the LICENSE file.
55

66
import os
7-
from typing import Dict, Optional
87

98
URL = 'https://emscripten.org'
109
DESCRIPTION = 'Test Description'
@@ -18,7 +17,7 @@
1817
}
1918

2019
# user options (from --use-port)
21-
opts: Dict[str, Optional[str]] = {
20+
opts: dict[str, str | None] = {
2221
'value1': None,
2322
'value2': None,
2423
'value3': "v3",

test/parallel_testsuite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def log_test_run_for_visualization(self, flaky_tests):
315315
# block, so generate one on the fly.
316316
dummy_test_task_counter = os.path.getsize(profiler_log_file) if os.path.isfile(profiler_log_file) else 0
317317
# Remove the redundant 'test_' prefix from each test, since character space is at a premium in the visualized graph.
318-
test_name = utils.removeprefix(self.test_short_name(), 'test_')
318+
test_name = self.test_short_name().removeprefix('test_')
319319
with open(profiler_log_file, 'a') as prof:
320320
prof.write(f',\n{{"pid":{dummy_test_task_counter},"op":"start","time":{self.start_time},"cmdLine":["{test_name}"],"color":"{color}"}}')
321321
prof.write(f',\n{{"pid":{dummy_test_task_counter},"op":"exit","time":{self.start_time + self.test_duration},"returncode":0}}')

test/runner.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,7 @@ def parse_args():
482482
parser.add_argument('--verbose', '-v', action='count', default=0,
483483
help="Show test stdout and stderr, and don't use the single-line test reporting. "
484484
'Specifying `-v` twice will enable test framework logging (i.e. EMTEST_VERBOSE)')
485-
# TODO: Replace with BooleanOptionalAction once we can depend on python3.9
486-
parser.add_argument('--ansi', action='store_true', default=None)
487-
parser.add_argument('--no-ansi', action='store_false', dest='ansi', default=None)
485+
parser.add_argument('--ansi', action=argparse.BooleanOptionalAction, default=None)
488486
parser.add_argument('--all-engines', action='store_true')
489487
parser.add_argument('--detect-leaks', action='store_true')
490488
parser.add_argument('--skip-slow', action='store_true', help='Skip tests marked as slow')

test/sockets/socket_relay.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@
1818
import sys
1919
import threading
2020
import time
21-
from typing import Optional
2221

2322
ports = [int(sys.argv[1]), int(sys.argv[2])]
2423

2524

2625
class Listener(threading.Thread):
27-
other: Optional[Listener] = None # noqa: F821
26+
other: Listener | None = None # noqa: F821
2827

2928
def run(self):
3029
self.conn = None

test/test_benchmark.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import unittest
1414
import zlib
1515
from pathlib import Path
16-
from typing import List
1716

1817
if __name__ == '__main__':
1918
raise Exception('do not run this file directly; do something like: test/runner.py benchmark')
@@ -137,7 +136,7 @@ def add_stat(name, size, gzip_size):
137136
size = os.path.getsize(file)
138137
gzip_size = len(zlib.compress(read_binary(file)))
139138
if self.record_stats:
140-
add_stat(utils.removeprefix(os.path.basename(file), 'size_'), size, gzip_size)
139+
add_stat(os.path.basename(file).removeprefix('size_'), size, gzip_size)
141140
total_size += size
142141
total_gzip_size += gzip_size
143142

@@ -353,7 +352,7 @@ def get_output_files(self):
353352

354353
# Benchmarkers
355354

356-
benchmarkers: List[Benchmarker] = []
355+
benchmarkers: list[Benchmarker] = []
357356

358357
# avoid the baseline compiler running, because it adds a lot of noise
359358
# (the nondeterministic time it takes to get to the full compiler ends up

test/test_other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2982,7 +2982,7 @@ def test_extern_prepost(self):
29822982
def test_js_optimizer(self, passes, filename=None):
29832983
if not filename:
29842984
testname = self.id().split('.')[-1]
2985-
filename = utils.removeprefix(testname, 'test_js_optimizer_') + '.js'
2985+
filename = testname.removeprefix('test_js_optimizer_') + '.js'
29862986
filename = test_file('js_optimizer', filename)
29872987
expected_file = utils.unsuffixed(filename) + '-output.js'
29882988
# test calling optimizer

0 commit comments

Comments
 (0)