Skip to content
Open
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
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[build-system]
requires = [
"numpy<2.0; python_version<'3.9'",
"numpy==2.0.2; python_version>='3.9' and python_version<'3.13'",
"numpy==2.0.2; python_version>='3.9' and python_version<'3.13' and platform_machine!='ARM64'",
"numpy>=2.3.0; python_version>='3.9' and python_version<'3.13' and platform_machine=='ARM64'",
"numpy==2.1.3; python_version=='3.13'",
"numpy==2.3.2; python_version=='3.14'",
"packaging",
Expand Down
16 changes: 12 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,10 @@ 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",
# Adreno GPUs (used on Windows ARM64 devices) produce numerically
# divergent OpenCL kernel results.
"-DWITH_OPENCL=OFF"]
Comment thread
asmorkalov marked this conversation as resolved.
Resolved
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
Loading