From bb3d60020fbdd53e2968c02a5283a9e8fd1ece99 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Fri, 8 Nov 2024 17:52:11 +0100 Subject: [PATCH] `make_test_list.py`: Parse the version out of Makefile.envs This fixes `make_test_list.py` so it can be run with any version of Python as opposed to having to match the Python version Pyodide uses. --- src/tests/make_test_list.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/tests/make_test_list.py b/src/tests/make_test_list.py index d4b6b7d0dde..bd6c8046563 100644 --- a/src/tests/make_test_list.py +++ b/src/tests/make_test_list.py @@ -4,18 +4,41 @@ import os from pathlib import Path -from sys import version from typing import Any +import subprocess import ruamel.yaml yaml = ruamel.yaml.YAML() PYODIDE_ROOT = Path(__file__).parents[2] -LIB_DIR = PYODIDE_ROOT / "cpython/build" f"/Python-{version.split(' ')[0]}" f"/Lib/" - PYTHON_TESTS_YAML = Path(__file__).parent / "python_tests.yaml" +def get_makefile_envs(): + result = subprocess.run( + ["make", "-f", str(PYODIDE_ROOT / "Makefile.envs"), ".output_vars"], + capture_output=True, + text=True, + env={"PYODIDE_ROOT": str(PYODIDE_ROOT)}, + ) + + if result.returncode != 0: + logger.error("ERROR: Failed to load environment variables from Makefile.envs") + exit_with_stdio(result) + + environment = {} + for line in result.stdout.splitlines(): + equalPos = line.find("=") + if equalPos != -1: + varname = line[0:equalPos] + + value = line[equalPos + 1 :] + value = value.strip("'").strip() + environment[varname] = value + + return environment + + def get_old_yaml(): try: with open(PYTHON_TESTS_YAML) as fp: @@ -69,6 +92,8 @@ def update_tests(doc_group, tests): if __name__ == "__main__": doc = get_old_yaml() + version = get_makefile_envs()["PYVERSION"] + LIB_DIR = PYODIDE_ROOT / "cpython/build" f"/Python-{version}/Lib/" update_tests(doc, collect_tests(LIB_DIR / "test")) yaml.dump(doc, PYTHON_TESTS_YAML)