Skip to content

Commit 5dd4eea

Browse files
committed
Handle multiple Python versions in build_test_matrix
1 parent 7410b91 commit 5dd4eea

3 files changed

Lines changed: 36 additions & 3 deletions

File tree

.github/workflows/main.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ on:
1212
pyodide-version:
1313
required: false
1414
type: string
15-
default: "0.27.2"
15+
default: "0.29.3"
16+
python-version:
17+
required: false
18+
type: string
19+
default: "3.13"
1620
os:
1721
required: false
1822
type: string
@@ -102,7 +106,7 @@ jobs:
102106

103107
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
104108
with:
105-
python-version: 3.12
109+
python-version: ${{ inputs.python-version }}
106110

107111
- name: install pyodide-py
108112
run: |

.github/workflows/testall.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ jobs:
8080
build-artifact-name: ${{ inputs.build-artifact-name }}
8181
build-artifact-path: ${{ inputs.build-artifact-path }}
8282
pyodide-version: ${{ matrix.pyodide_version }}
83+
python-version: ${{ matrix.python_version }}
8384
os: ${{ matrix.os }}
8485
runner: ${{ matrix.runner }}
8586
browser: ${{ matrix.browser }}

utils/build_test_matrix.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,27 @@
1818
DEFAULT_PLAYWRIGHT_VERSION = "1.44.0"
1919

2020

21+
@dataclasses.dataclass
22+
class VersionPair:
23+
pyodide_version: tuple[int, int]
24+
python_version: str
25+
26+
27+
PYODIDE_TO_PYTHON_VERSION: list[VersionPair] = [
28+
VersionPair(pyodide_version=(0, 28), python_version="3.13"),
29+
VersionPair(pyodide_version=(0, 25), python_version="3.12"),
30+
VersionPair(pyodide_version=(0, 23), python_version="3.11"),
31+
]
32+
33+
34+
def python_version_for_pyodide(pyodide_version: str) -> str:
35+
pyodide_ver = tuple(int(x) for x in pyodide_version.split(".")[:2])
36+
for pair in PYODIDE_TO_PYTHON_VERSION:
37+
if pyodide_ver >= pair.pyodide_version:
38+
return pair.python_version
39+
return "3.10"
40+
41+
2142
@dataclasses.dataclass
2243
class TestConfig:
2344
pyodide_version: str
@@ -26,6 +47,7 @@ class TestConfig:
2647
browser: str
2748
browser_version: str = ""
2849
playwright_version: str = ""
50+
python_version: str = ""
2951

3052
@property
3153
def runtime(self) -> str:
@@ -130,7 +152,13 @@ def build_configs(args: dict[str, list[str]]) -> list[TestConfig]:
130152
for _os, _pyodide_version, _runner, _browser in itertools.product(
131153
os, pyodide_version, runner, browser
132154
):
133-
config = TestConfig(_pyodide_version, _os, _runner, _browser)
155+
config = TestConfig(
156+
_pyodide_version,
157+
_os,
158+
_runner,
159+
_browser,
160+
python_version=python_version_for_pyodide(_pyodide_version),
161+
)
134162

135163
if not is_valid_config(config):
136164
continue

0 commit comments

Comments
 (0)