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

Emscripten wheels generate invalid "unreachable" #62

Closed
ethanhs opened this issue Feb 10, 2023 · 2 comments · Fixed by python/mypy#14888
Closed

Emscripten wheels generate invalid "unreachable" #62

ethanhs opened this issue Feb 10, 2023 · 2 comments · Fixed by python/mypy#14888

Comments

@ethanhs
Copy link
Collaborator

ethanhs commented Feb 10, 2023

I think this is probably not a bug in mypyc, more of how we build mypy with mypyc for Emscripten. When I set MYPY_FORCE_COLOR=1 in the Emscripten environment, I get the following error:

Traceback (most recent call last):
  File "mypy/api.py", line 71, in run
    return _run(
  File "mypy/api.py", line 59, in _run
    main_wrapper(stdout, stderr)
  File "mypy/api.py", line 72, in <lambda>
    lambda stdout, stderr: main(args=args, stdout=stdout, stderr=stderr, clean_exit=True)
  File "mypy/main.py", line 70, in main
    formatter = util.FancyFormatter(stdout, stderr, options.hide_error_codes)
  File "mypy/util.py", line 547, in __init__
    elif sys.platform == "emscripten":
RuntimeError: Reached allegedly unreachable code!

Which comes from this line in the color output detection code. The error is that the sys.platform is not emscripten as it should be, so I believe the solution is that we need to override the sys.platform when building Emscripten wheels. I want to check with pyodide folks first to make sure there isn't something else we should be doing however.

@JelleZijlstra
Copy link

cc @ethanhs

@ethanhs
Copy link
Collaborator Author

ethanhs commented Mar 13, 2023

I decided this would be better as a change to mypy's options: python/mypy#14888

wesleywright pushed a commit to python/mypy that referenced this issue Apr 24, 2023
This is a workaround for correctly detecting the platform when building
mypy with mypyc on the Emscripten platform. This fixes
mypyc/mypy_mypyc-wheels#62. `pyodide build`
overrides `sysconfig` for the host based on the target (confirmed on the
pyodide matrix, [see also where the code is actually
changed](https://github.com/pyodide/pyodide/blob/e835bf05ff4aa463024aaeb9689ae70ea5771314/pyodide-build/pyodide_build/pypabuild.py#L43-L50)).

This should only change things when checking/building for the emscripten
platform. There isn't really a cleaner workaround that I can think of
unfortunately, the main issue is cross compiling is tricky with
setuptools.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants