From 3a6e16457d15dcdc8364b2869f0beecd79b186cb Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 9 Jul 2026 22:10:41 +0530 Subject: [PATCH] Use PYODIDE environment variable for Emscripten cross-compilation detection --- mypy/options.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mypy/options.py b/mypy/options.py index 2f03cd3eab5b7..92c9ea3b1701d 100644 --- a/mypy/options.py +++ b/mypy/options.py @@ -1,9 +1,9 @@ from __future__ import annotations +import os import pprint import re import sys -import sysconfig from collections.abc import Callable from re import Pattern from typing import Any, Final @@ -112,11 +112,11 @@ def __init__(self) -> None: # then mypy does not search for PEP 561 packages. self.python_executable: str | None = sys.executable - # When cross compiling to emscripten, we need to rely on MACHDEP because - # sys.platform is the host build platform, not emscripten. - MACHDEP = sysconfig.get_config_var("MACHDEP") - if MACHDEP == "emscripten": - self.platform = MACHDEP + # When cross compiling to emscripten, sys.platform is the host build + # platform, not emscripten. Pyodide sets the PYODIDE environment variable + # at build time, so we use it to detect the emscripten target. + if "PYODIDE" in os.environ: + self.platform = "emscripten" else: self.platform = sys.platform