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

add support for building windows/arm64 package #644

Merged
merged 1 commit into from Apr 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 12 additions & 6 deletions setup.py
Expand Up @@ -60,7 +60,7 @@ def main():
)

# https://stackoverflow.com/questions/1405913/python-32bit-or-64bit-mode
x64 = sys.maxsize > 2 ** 32
is64 = sys.maxsize > 2 ** 32

package_name = "opencv-python"

Expand Down Expand Up @@ -88,7 +88,7 @@ def main():
# Path regexes with forward slashes relative to CMake install dir.
rearrange_cmake_output_data = {
"cv2": (
[r"bin/opencv_videoio_ffmpeg\d{3}%s\.dll" % ("_64" if x64 else "")]
[r"bin/opencv_videoio_ffmpeg\d{3}%s\.dll" % ("_64" if is64 else "")]
if os.name == "nt"
else []
)
Expand Down Expand Up @@ -130,7 +130,7 @@ def main():
files_outside_package_dir = {"cv2": ["LICENSE.txt", "LICENSE-3RD-PARTY.txt"]}

ci_cmake_generator = (
["-G", "Visual Studio 14" + (" Win64" if x64 else "")]
["-G", "Visual Studio 14" + (" Win64" if is64 else "")]
if os.name == "nt"
else ["-G", "Unix Makefiles"]
)
Expand Down Expand Up @@ -164,9 +164,15 @@ def main():
"-DBUILD_PNG=ON",
]
+ (
# CMake flags for windows/arm64 build
["-DCMAKE_GENERATOR_PLATFORM=ARM64",
asmorkalov marked this conversation as resolved.
Show resolved Hide resolved
# Emulated cmake requires following flags to correctly detect
# target architecture for windows/arm64 build
"-DOPENCV_WORKAROUND_CMAKE_20989=ON",
"-DCMAKE_SYSTEM_PROCESSOR=ARM64"]
asmorkalov marked this conversation as resolved.
Show resolved Hide resolved
if platform.machine() == "ARM64" and sys.platform == "win32"
# If it is not defined 'linker flags: /machine:X86' on Windows x64
["-DCMAKE_GENERATOR_PLATFORM=x64"]
if x64 and sys.platform == "win32"
else ["-DCMAKE_GENERATOR_PLATFORM=x64"] if is64 and sys.platform == "win32"
else []
)
+ (
Expand All @@ -186,7 +192,7 @@ def main():
"-DWITH_MSMF=OFF"
) # see: https://github.com/skvark/opencv-python/issues/263

if sys.platform.startswith("linux") and not x64 and "bdist_wheel" in sys.argv:
if sys.platform.startswith("linux") and not is64 and "bdist_wheel" in sys.argv:
subprocess.check_call("patch -p0 < patches/patchOpenEXR", shell=True)

# OS-specific components during CI builds
Expand Down