-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Enable arm64 for MSVC on Windows #5811
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
Conversation
39ec132
to
3c24aa3
Compare
Could you please post the full Pytest output? In particular, I would be interested in seeing the skips and the list of loaded dependencies (at the start of the output). |
x64_pytests_full.txt I attach the x64 results as a reference also as it looks that there 3 common failing tests. |
winbuild/build.rst
Outdated
@@ -42,8 +42,8 @@ behaviour of ``build_prepare.py``: | |||
If ``PYTHON`` is unset, the version of Python used to run | |||
``build_prepare.py`` will be used. If only ``PYTHON`` is set, | |||
``EXECUTABLE`` defaults to ``python.exe``. | |||
* ``ARCHITECTURE`` is used to select a ``x86`` or ``x64`` build. By default, | |||
uses same architecture as the version of Python used to run ``build_prepare.py``. | |||
* ``ARCHITECTURE`` is used to select a ``x86``, ``x64`` or ``x86_arm64`` (for win-arm64) build. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x86_arm64
seems very odd to see... why not simply arm64
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it's strange.
It's coming from vcvarsall.bat (attached) and the fact the win-arm64 MSVC compiler is basically a cross-compiler, not native arm64. The host is working in x86 emulation mode.
vcvarsall.bat.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, got it. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is an internal value only used by Pillow, there is nothing preventing the use of arm64
. In fact, while vcvarsall
uses x86_arm64
, MSBuild uses ARM64
(according to this PR, I haven't checked myself). The x64
value already disagrees with vcvarsall
's x86_amd64
. So I would also vote for either arm64
or ARM64
. Of the two, I would probably prefer ARM64
to match platform.machine()
, but either is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, updated!
Is this testable on GitHub Actions? |
Not yet unfortunately. |
3c24aa3
to
69c888a
Compare
I've investigated the following test: test_image_access.py::TestEmbeddable::test_embeddable It's only enabled local Windows run: https://github.com/python-pillow/Pillow/blob/main/Tests/test_image_access.py#L399 I tend to think this test should be removed or fix for all platforms as it should be a platform agnostic test as embedding into C/C++ code should be universal. I see several issues:
|
For reference, 3221225477 == 0xC0000005, i.e. access violation. From MSDN:
|
Thanks! However my main question is: |
As far as I'm concerned, I wasn't around when the test was added, and I haven't seen it pass on Windows in the past 2 years. I've also not looked into it further myself. |
Wouldn't it be a right time to remove this test to avoid further confusion? |
@radarhere @nulano @hugovk Sorry for the reminder, but can I do anything to close this PR? |
b7428b1
to
7687186
Compare
winbuild/build_prepare.py
Outdated
# commit: Merge branch 'master' into msvc (matches 2.16.0 tag) | ||
"url": "https://github.com/ImageOptim/libimagequant/archive/f41ee301ff3a407b16991af3dbe03910919bbdc3.zip", # noqa: E501 | ||
"filename": "libimagequant-f41ee301ff3a407b16991af3dbe03910919bbdc3.zip", | ||
"dir": "libimagequant-f41ee301ff3a407b16991af3dbe03910919bbdc3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why switch to the master branch here? As the comment says, previously this used the msvc branch, so the 2.17.0 equivalent would be ImageOptim/libimagequant@e4c1334
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated to the 2.17.0 version of the msvc branch in #5916
* ``ARCHITECTURE`` is used to select a ``x86`` or ``x64`` build. By default, | ||
uses same architecture as the version of Python used to run ``build_prepare.py``. | ||
* ``ARCHITECTURE`` is used to select a ``x86``, ``x64`` or ``ARM64``build. | ||
By default, uses same architecture as the version of Python used to run ``build_prepare.py``. | ||
is used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems to have disappered in a force-push. Is there any reason not to include it anymore?
is used. | |
is used. Note that the ``ARM64`` build is not fully supported and some dependencies may fail to build. Pull requests are welcome. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I didn't mention that LittleCMS is the last dependency and VS2019 update is merged, just not released yet:
mm2/Little-CMS#288
Patch to use VS2019 project: gaborkertesz-linaro@0af6042
So if either VS2019 project is accepted or VS2017 will be updated for ARM64 as well and LCMS2 is released, all external dependencies will be enabled.
Probably this pull request can be blocked until updated LCMS2 is released.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lcms2 2.13 has now been released.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the heads up, I'm going to rebase my changes and run the tests!
7687186
to
def67cf
Compare
def67cf
to
3da0c59
Compare
Could you please re-run the tests with PATH %PATH%;C:\kg\python_test\github_packages\Pillow\winbuild\build\bin
"C:\kg\python_test\venv_310_new\Scripts\python.exe" -m pytest -v Tests |
This patch enables ARM64 as a new platform for Windows. Platform query and documentation is updated accordingly.
In order to enable win-arm64, VS2019 should be used, while other platforms should work with newer version as well. Tested on x64-win10.
3da0c59
to
22a1f6d
Compare
05_Tests2.log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, looks mostly good.
The first three failures seem to be a difference in floating point rounding:
FAILED Tests/test_color_lut.py::TestTransformColorLut3D::test_3_to_4_channels
At index 4 diff: 0.04000000000000001 != 0.04
FAILED Tests/test_color_lut.py::TestTransformColorLut3D::test_4_to_4_channels
At index 4 diff: 0.04000000000000001 != 0.04
FAILED Tests/test_color_lut.py::TestTransformColorLut3D::test_with_normals_3_channels
At index 12 diff: 0.15999999999999992 != 0.16000000000000003
The next two could be caused by a similar difference, being a small margin above the epsilon (but hard to be sure without visually inspecting the images):
FAILED Tests/test_file_wmf.py::test_load_raw - AssertionError: average pixel value difference 2.0479 > epsilon 2.0000
FAILED Tests/test_file_wmf.py::test_load_set_dpi - AssertionError: average pixel value difference 2.6547 > epsilon 2.1000
The next failed test I have never seen pass on Windows:
FAILED Tests/test_image_access.py::TestEmbeddable::test_embeddable - distutil...
And the last one could be due to how the tests are being run. Are you running the tests directly in a desktop session, or are you using some sort of terminal without a desktop, e.g. SSH? Either way this seems like a separate issue unrelated to ARM.
FAILED Tests/test_imagegrab.py::TestImageGrab::test_grab - OSError: screen grab failed
I connect to my local PC via remote desktop and run the tests in Windows Terminal, so I'd expect this shouldn't prevent screengrab. Probably as a follow-up taks this could be investigated. |
Thanks for the thorough and persistent support! |
A small clarification: Pillow doesn't use libpng, HarfBuzz, FriBiDi directly. These are only listed in build_prepare because they are used by the other libraries. Specifically, libpng is used by FreeType to support color fonts in CBDT/SBIX format, and HarfBuzz/FriBiDi are dependencies of Raqm. Raqm used to be built directly, but as of Pillow 8.2.0 a modified version is included in the sources and is now the default on Windows. For details see: https://pillow.readthedocs.io/en/stable/installation.html#external-libraries |
Thanks, I'll fix these issues! |
I don't understand your question. Doing a grep for libpng in Pillow only shows build_prepare.py and test-windows.yml for me, the latter containing a comment that libpng is only used by FreeType. Are you asking why build_prepare generates a script to compile the indirect dependencies? The VS2010 build of FreeType doesn't build libpng directly, libpng must already be present and compiled somewhere, so build_prepare takes care of that. |
Thanks, yes, that was my concern that FreeTypes includes libpng dependency in its source and I'd expect that ideally it should take care of build dependencies: |
This patch enabled win-arm64 as a new platform for Windows.
Platform query and documentation is updated accordingly.