From 8d5d84e0fc10b6a93d9997e61e1f9a48bf373987 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Tue, 11 Jun 2024 02:48:42 -0400 Subject: [PATCH] fix: accept current Python version if acceptable for Pyodide (#1868) * fix: accept current Python version if acceptable for Pyodide Signed-off-by: Henry Schreiner --- action.yml | 4 ++-- cibuildwheel/pyodide.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 87057a947..4f8ff6796 100644 --- a/action.yml +++ b/action.yml @@ -24,11 +24,11 @@ branding: runs: using: composite steps: - # Set up a non-EOL, cibuildwheel & pipx supported Python version + # Set up the version of Python that supports pyodide - uses: actions/setup-python@v5 id: python with: - python-version: "3.8 - 3.12" + python-version: "3.12" update-environment: false - id: cibw diff --git a/cibuildwheel/pyodide.py b/cibuildwheel/pyodide.py index 67488edce..d2ca04591 100644 --- a/cibuildwheel/pyodide.py +++ b/cibuildwheel/pyodide.py @@ -2,6 +2,7 @@ import os import shutil +import sys from collections.abc import Sequence, Set from dataclasses import dataclass from pathlib import Path @@ -92,7 +93,11 @@ def install_xbuildenv(env: dict[str, str], pyodide_version: str) -> str: def get_base_python(identifier: str) -> Path: implementation_id = identifier.split("-")[0] majorminor = implementation_id[len("cp") :] - major_minor = f"{majorminor[0]}.{majorminor[1:]}" + version_info = (int(majorminor[0]), int(majorminor[1:])) + if version_info == sys.version_info[:2]: + return Path(sys.executable) + + major_minor = ".".join(str(v) for v in version_info) python_name = f"python{major_minor}" which_python = shutil.which(python_name) if which_python is None: