Skip to content

Commit 5de8d66

Browse files
authored
Merge pull request #644 from nsait-linaro/windows-arm64
add support for building windows/arm64 package
2 parents 8f2049e + 7419f58 commit 5de8d66

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

setup.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def main():
6060
)
6161

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

6565
package_name = "opencv-python"
6666

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

132132
ci_cmake_generator = (
133-
["-G", "Visual Studio 14" + (" Win64" if x64 else "")]
133+
["-G", "Visual Studio 14" + (" Win64" if is64 else "")]
134134
if os.name == "nt"
135135
else ["-G", "Unix Makefiles"]
136136
)
@@ -164,9 +164,15 @@ def main():
164164
"-DBUILD_PNG=ON",
165165
]
166166
+ (
167+
# CMake flags for windows/arm64 build
168+
["-DCMAKE_GENERATOR_PLATFORM=ARM64",
169+
# Emulated cmake requires following flags to correctly detect
170+
# target architecture for windows/arm64 build
171+
"-DOPENCV_WORKAROUND_CMAKE_20989=ON",
172+
"-DCMAKE_SYSTEM_PROCESSOR=ARM64"]
173+
if platform.machine() == "ARM64" and sys.platform == "win32"
167174
# If it is not defined 'linker flags: /machine:X86' on Windows x64
168-
["-DCMAKE_GENERATOR_PLATFORM=x64"]
169-
if x64 and sys.platform == "win32"
175+
else ["-DCMAKE_GENERATOR_PLATFORM=x64"] if is64 and sys.platform == "win32"
170176
else []
171177
)
172178
+ (
@@ -186,7 +192,7 @@ def main():
186192
"-DWITH_MSMF=OFF"
187193
) # see: https://github.com/skvark/opencv-python/issues/263
188194

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

192198
# OS-specific components during CI builds

0 commit comments

Comments
 (0)