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

Windows arm64 dependency cross-compilation fixes #7559

Merged
merged 2 commits into from
Nov 19, 2023

Conversation

nulano
Copy link
Contributor

@nulano nulano commented Nov 16, 2023

For #6679 and #7390 (comment)

When compiling Pillow directly on an ARM64 system, I found it worked after installing the correct Visual Studio components.
Cross-compiling required a few patches to the dependencies.

Changes proposed in this pull request:

elif args.architecture == "ARM64" and platform.machine() != "ARM64":
print(
"\nWarning: Cross-compiling FriBiDi is currently not supported, disabling"
)
Copy link
Member

Choose a reason for hiding this comment

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

You didn't want to use warnings.warn()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't like that it can sometimes appear at a random point in the output due to using stderr instead of stdout so I hadn't even tested it. I've just tried it and found that:

  • in Terminal, it seems to always print in the intended order;
  • in PyCharm, it can print out of order, but uses a red highlight.

I've therefore changed the code to use warnings.warn.

winbuild/build_prepare.py Outdated Show resolved Hide resolved
# libjpeg-turbo does not detect MSVC x86_arm64 cross-compiler correctly
'if(MSVC_IDE AND CMAKE_GENERATOR_PLATFORM MATCHES "arm64")': "if({architecture} STREQUAL ARM64)", # noqa: E501
},
},
Copy link
Member

Choose a reason for hiding this comment

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

Is this change something that could be suggested to https://github.com/libjpeg-turbo/libjpeg-turbo, so that it could one day no longer require patching?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, not easily.
CMake does not provide a value for the target CPU architecture, only the host CPU architecture: https://stackoverflow.com/a/12024211/1648883
The {architecture} string here is referring to the Python value from

"architecture": args.architecture,

Co-authored-by: Hugo van Kemenade <[email protected]>
@radarhere radarhere merged commit d9d11b9 into python-pillow:main Nov 19, 2023
55 of 56 checks passed
@nulano nulano deleted the arm_build branch November 20, 2023 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants