Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions .github/workflows/build_wheels_windows.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Windows x86_64
name: Windows

on:
pull_request:
Expand All @@ -17,12 +17,11 @@ on:

jobs:
Build:
runs-on: windows-2022
runs-on: ${{ matrix.platform == 'arm64' && 'windows-11-arm' || 'windows-2022' }}
strategy:
fail-fast: false
matrix:
python-version: ['3.9']
platform: [x86, x64]
platform: [x86, x64, arm64]
with_contrib: [0, 1]
without_gui: [0, 1]
build_sdist: [0]
Expand All @@ -32,6 +31,7 @@ jobs:
ENABLE_HEADLESS: ${{ matrix.without_gui }}
ENABLE_CONTRIB: ${{ matrix.with_contrib }}
OPENCV_TEST_DATA_PATH: ${{ github.workspace }}\opencv_extra\testdata
PYTHON_VERSION: ${{ matrix.platform == 'arm64' && '3.11' || '3.9' }}
steps:
- name: Cleanup
shell: bash
Expand All @@ -50,17 +50,20 @@ jobs:
with:
submodules: false
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ env.PYTHON_VERSION }}
architecture: ${{ matrix.platform }}
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1.1
with:
msbuild-architecture: ${{ matrix.platform }}
- name: Setup NASM
if: matrix.platform != 'arm64'
uses: ilammy/setup-nasm@v1
- name: Build a package
# CMake 3.25 regression fix. See https://stackoverflow.com/questions/74162633/problem-compiling-from-source-opencv-with-mvsc2019-in-64-bit-version
# CMake 3.25 regression fix for x86/x64. See https://stackoverflow.com/questions/74162633/problem-compiling-from-source-opencv-with-mvsc2019-in-64-bit-version
run: |
python --version
python -m pip install --upgrade pip
Expand All @@ -77,18 +80,26 @@ jobs:

Test:
needs: [Build]
runs-on: windows-2022
runs-on: ${{ matrix.platform == 'arm64' && 'windows-11-arm' || 'windows-2022' }}
defaults:
run:
shell: cmd
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
platform: [x86, x64]
platform: [x86, x64, arm64]
with_contrib: [0, 1]
without_gui: [0, 1]
build_sdist: [0]
exclude:
# actions/setup-python does not provide prebuilt arm64 Python before 3.11
- platform: arm64
python-version: '3.8'
- platform: arm64
python-version: '3.9'
- platform: arm64
python-version: '3.10'
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
OPENCV_TEST_DATA_PATH: ${{ github.workspace }}\opencv_extra\testdata
Expand Down
19 changes: 15 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ def main():

# Files from CMake output to copy to package.
# Path regexes with forward slashes relative to CMake install dir.
# Note: FFMPEG dlls are not yet provided for Windows ARM64
rearrange_cmake_output_data = {
"cv2": (
[r"bin/opencv_videoio_ffmpeg\d{3}%s\.dll" % ("_64" if is64 else "")]
if os.name == "nt"
if os.name == "nt" and not (platform.machine() == "ARM64" and sys.platform == "win32")
else []
)
+
Expand Down Expand Up @@ -157,9 +158,13 @@ def main():

# HACK: Disabled generic assembler for now.
# Windows 2025 CI environment does not provide suitable assembler or build is broken in OpenCV MLAS.
# On ARM64, NOTFOUND also avoids a MinGW toolchain on PATH being misdetected by CMake's ASM probe.
ci_cmake_generator = (
["-G", "Visual Studio 17 2022",
"-DCMAKE_ASM_COMPILER="]
["-G", "Visual Studio 18 2026",
"-DCMAKE_ASM_COMPILER=CMAKE_ASM_COMPILER-NOTFOUND"]
if os.name == "nt" and platform.machine() == "ARM64"
else ["-G", "Visual Studio 17 2022",
"-DCMAKE_ASM_COMPILER="]
if os.name == "nt"
else ["-G", "Unix Makefiles"]
)
Expand Down Expand Up @@ -198,7 +203,8 @@ def main():
# Emulated cmake requires following flags to correctly detect
# target architecture for windows/arm64 build
"-DOPENCV_WORKAROUND_CMAKE_20989=ON",
"-DCMAKE_SYSTEM_PROCESSOR=ARM64"]
"-DCMAKE_SYSTEM_PROCESSOR=ARM64",
"-DWITH_OPENCL=OFF"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why is OpenCV disabled? OpenCV dynamically check OpenCL availability in runtime. The option looks redundant for me.

if platform.machine() == "ARM64" and sys.platform == "win32"
# If it is not defined 'linker flags: /machine:X86' on Windows x64
else ["-DCMAKE_GENERATOR_PLATFORM=x64"] if is64 and sys.platform == "win32"
Expand Down Expand Up @@ -264,6 +270,11 @@ def main():
cmake_args.append("-DWITH_LAPACK=ON")
cmake_args.append("-DENABLE_PRECOMPILED_HEADERS=OFF")

if sys.platform.startswith('win') and platform.machine().lower() in ("arm64", "aarch64"):
# MSVC does not support OpenCV dispatch features such as NEON_FP16, NEON_BF16 and NEON_DOTPROD. So use NEON as both baseline and dispatch units
cmake_args.append("-DCPU_BASELINE=NEON")
cmake_args.append("-DCPU_DISPATCH=NEON")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's redundant. Current OpenCV CMake already defines NEON as baseline. Main OpenCV CI: https://github.com/opencv/opencv/actions/runs/42283223084/job/128327194332?pr=30704

# works via side effect
RearrangeCMakeOutput(
rearrange_cmake_output_data, files_outside_package_dir, package_data.keys()
Expand Down
Loading