Skip to content

Commit

Permalink
Merge pull request #644 from nsait-linaro/windows-arm64
Browse files Browse the repository at this point in the history
add support for building windows/arm64 package
  • Loading branch information
asmorkalov committed Apr 12, 2022
2 parents 8f2049e + 7419f58 commit 5de8d66
Showing 1 changed file with 12 additions and 6 deletions.
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",
# Emulated cmake requires following flags to correctly detect
# target architecture for windows/arm64 build
"-DOPENCV_WORKAROUND_CMAKE_20989=ON",
"-DCMAKE_SYSTEM_PROCESSOR=ARM64"]
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

0 comments on commit 5de8d66

Please sign in to comment.