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

[WIP] Fixes to get unit tests working for Arm64 and Visual Studio 2022 Preview #18673

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Blackhex
Copy link

@Blackhex Blackhex commented Feb 7, 2023

This PR is heavily WIP. I am just wondering whether the test\runner.py tests are runing for Windows on the CI as they seem quite outdated.

@Blackhex Blackhex force-pushed the fix-unit-tests-arm64 branch from f2cce1b to d3def69 Compare February 7, 2023 09:17
@@ -25,7 +25,7 @@
from tools import ports

SANITY_FILE = cache.get_path('sanity.txt')
commands = [[EMCC], [path_from_root('test/runner'), 'blahblah']]
commands = [[EMCC], [path_from_root('test/runner.bat'), 'blahblah']]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the shared.bat_suffix helper here perhaps?

embuilder.py Outdated
import time
from contextlib import contextmanager

__rootpath__ = os.path.dirname(os.path.abspath(__file__))
sys.path.append(__rootpath__)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why these changes would be needed? Isn't python supposed to include the script directory implicitly? What version of python are you using here?

Copy link
Author

@Blackhex Blackhex Feb 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, I am testing it with the official Arm64 Python binaries (https://www.python.org/ftp/python/3.11.1/python-3.11.1-embed-arm64.zip) installed and activated by emsdk.py. But I am experiencing the same issue on a x64 machine with Python interpreter obtained from emsdk install latest. It's also a mystery to me that I am currently trying to solve. For some reason, the %EMSDK_PYTHON% Python interpreter is ignoring PYTHONPATH variable (even when -E argument is removed from bat files) and it does not contain current working dir in sys.path by default.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But you shouldn't need to set PYTHONPATH at all should you?

The current working directory is not normally part of sys.path but the script directory certainly should be.

e.g.:

$ cat emscripten/test.py 
import sys
print(sys.path)
$ pwd
/usr/local/google/home/sbc/dev/wasm
$ python3 emscripten/test.py
['/usr/local/google/home/sbc/dev/wasm/emscripten', '/usr/local/buildtools/current/sitecustomize', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/usr/local/google/home/sbc/.local/lib/python3.10/site-packages', '/usr/local/lib/python3.10/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.10/dist-packages']

Note that pwd does not appear in the path, but that script directory does.

Is there some reason you want to remove the -E from the python command?

Copy link
Author

@Blackhex Blackhex Feb 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your are right in every point. I am just not sure what you mean by "script directory"? site-packages? Nevertheless, currently I just need to find a simple workaround to continue working on making unit tests passing on Arm64 with Visual Studio 2022 and I'll figure out what is wrong with the Python interpreted acquired by emdsk.py later. With the system-wide Python-interpreter installed from EXE installer, the runner.py is loading the Python local scripts just fine.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbc100, JFYI, the workarounds for sys.path imports are related to this Python issue python/cpython#101867

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We intentionally don't use the embed versions of python for this (and perhaps other) reasons.

How are you installing python? Why not just use the distro package of python? this is what we normally use/recommend on linux. (Note that while the mac and windows versions of emsdk install python themselves the linux version expects you to have it installed already).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, you are trying to install on windows, not linux. See #16466 for when we switched to the nuget packages.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See scripts/update_python.py for how to build the patched nuget installer. I think you would need to modify that script to support non x86_64 arch.

Copy link
Author

@Blackhex Blackhex Feb 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See scripts/update_python.py for how to build the patched nuget installer. I think you would need to modify that script to support non x86_64 arch.

Great, thank you. That's actually what we are currently working on. Btw, why some Python packages listed in the emsdk_manifest.json contains "embed" in its name, e. g. https://storage.googleapis.com/webassembly/emscripten-releases-builds/deps/python-3.9.2-1-embed-amd64+pywin32.zip?

@Blackhex Blackhex changed the title Fixes to get unit tests working for ARM64 and Visual Studio 2022 Preview [WIP] Fixes to get unit tests working for ARM64 and Visual Studio 2022 Preview Feb 8, 2023
@Blackhex Blackhex force-pushed the fix-unit-tests-arm64 branch from d3def69 to d6527d9 Compare February 8, 2023 12:35
@Blackhex Blackhex changed the title [WIP] Fixes to get unit tests working for ARM64 and Visual Studio 2022 Preview [WIP] Fixes to get unit tests working for Arm64 and Visual Studio 2022 Preview Feb 8, 2023
@Blackhex Blackhex force-pushed the fix-unit-tests-arm64 branch 2 times, most recently from ec0eef2 to e059399 Compare February 15, 2023 11:36
@Blackhex Blackhex force-pushed the fix-unit-tests-arm64 branch from e059399 to 6704d77 Compare February 15, 2023 11:39
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 this pull request may close these issues.

2 participants