Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sys.platform when cross-compiling with emscripten #14888

Merged
merged 2 commits into from
Apr 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion mypy/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pprint
import re
import sys
import sysconfig
from typing import Any, Callable, Dict, Mapping, Pattern
from typing_extensions import Final

Expand Down Expand Up @@ -86,7 +87,15 @@ def __init__(self) -> None:
# The executable used to search for PEP 561 packages. If this is None,
# then mypy does not search for PEP 561 packages.
self.python_executable: str | None = sys.executable
self.platform = sys.platform

# 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
else:
self.platform = sys.platform

self.custom_typing_module: str | None = None
self.custom_typeshed_dir: str | None = None
# The abspath() version of the above, we compute it once as an optimization.
Expand Down