Skip to content

Commit 5d2a765

Browse files
authored
Merge branch 'main' into mathern/benchmark-workflow
2 parents b0099b2 + 693eae3 commit 5d2a765

6 files changed

Lines changed: 79 additions & 24 deletions

File tree

.github/workflows/build-wheel.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,17 @@ jobs:
8888
echo "Verifying wheels using twine check"
8989
twine check dist/*
9090
91-
- name: Build Windows wheel (x64)
91+
- name: Install ARM64 OpenSSL via vcpkg (Windows ARM64)
92+
if: runner.os == 'Windows' && inputs.architecture == 'arm64'
93+
shell: pwsh
94+
run: |
95+
# Static linking avoids runtime DLL load issues.
96+
& "$env:VCPKG_INSTALLATION_ROOT\vcpkg.exe" install openssl:arm64-windows-static-md
97+
$vcpkgRoot = "$env:VCPKG_INSTALLATION_ROOT\installed\arm64-windows-static-md"
98+
echo "OPENSSL_DIR=$vcpkgRoot" >> $env:GITHUB_ENV
99+
echo "OPENSSL_STATIC=1" >> $env:GITHUB_ENV
100+
101+
- name: Build Windows wheel
92102
if: runner.os == 'Windows'
93103
shell: pwsh
94104
run: |
@@ -107,6 +117,7 @@ jobs:
107117
# Download native artifacts
108118
Write-Host "Starting artifact download process..."
109119
Write-Host "C2PA_VERSION: $env:C2PA_VERSION"
120+
Write-Host "Architecture: ${{ inputs.architecture }}"
110121
111122
python scripts/download_artifacts.py "$env:C2PA_VERSION"
112123
@@ -115,8 +126,15 @@ jobs:
115126
Write-Host "src/c2pa/libs directory contents:"
116127
Get-ChildItem -Recurse -Path src/c2pa/libs
117128
129+
# Set platform tag based on architecture
130+
if ("${{ inputs.architecture }}" -eq "arm64") {
131+
$PLATFORM_TAG = "win_arm64"
132+
} else {
133+
$PLATFORM_TAG = "win_amd64"
134+
}
135+
118136
# Build wheel
119-
python setup.py bdist_wheel --plat-name win_amd64
137+
python setup.py bdist_wheel --plat-name $PLATFORM_TAG
120138
121139
# Verify wheel structure
122140
twine check dist/*
@@ -188,4 +206,4 @@ jobs:
188206
with:
189207
name: ${{ inputs.artifact-name }}
190208
path: dist
191-
if-no-files-found: error
209+
if-no-files-found: error

.github/workflows/build.yml

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,16 @@ jobs:
128128
github.event.pull_request.user.login == 'dependabot[bot]' ||
129129
contains(github.event.pull_request.labels.*.name, 'safe to test')
130130
131-
runs-on: windows-latest
131+
runs-on: ${{ matrix.runs-on }}
132+
133+
strategy:
134+
fail-fast: false
135+
matrix:
136+
include:
137+
- runs-on: windows-latest
138+
python-version: "3.10"
139+
- runs-on: windows-11-arm
140+
python-version: "3.11" # win-arm runner needs 3.11 atleast
132141

133142
steps:
134143
- name: Checkout repository
@@ -137,9 +146,20 @@ jobs:
137146
- name: Set up Python
138147
uses: actions/setup-python@v5
139148
with:
140-
python-version: "3.10"
149+
python-version: ${{ matrix.python-version }}
141150
cache: "pip"
142151

152+
- name: Install ARM64 OpenSSL via vcpkg (Windows ARM64)
153+
if: matrix.runs-on == 'windows-11-arm'
154+
shell: pwsh
155+
run: |
156+
# Pre-installed OpenSSL on runner fails build.
157+
# Static OpenSSL to avoid runtime DLL load complexities.
158+
& "$env:VCPKG_INSTALLATION_ROOT\vcpkg.exe" install openssl:arm64-windows-static-md
159+
$vcpkgRoot = "$env:VCPKG_INSTALLATION_ROOT\installed\arm64-windows-static-md"
160+
echo "OPENSSL_DIR=$vcpkgRoot" >> $env:GITHUB_ENV
161+
echo "OPENSSL_STATIC=1" >> $env:GITHUB_ENV
162+
143163
- name: Install project dependencies
144164
run: python -m pip install -r requirements.txt
145165

@@ -277,13 +297,17 @@ jobs:
277297
python-version: "3.10"
278298
architecture: ${{ matrix.target }}
279299
artifact-name: wheels-windows-${{ matrix.target }}
280-
runs-on: windows-latest
300+
runs-on: ${{ matrix.runs-on }}
281301
c2pa-version: ${{ needs.read-version.outputs.c2pa-native-version }}
282302
secrets:
283303
github-token: ${{ secrets.GITHUB_TOKEN }}
284304
strategy:
285305
matrix:
286-
target: [x64]
306+
include:
307+
- target: x64
308+
runs-on: windows-latest
309+
- target: arm64
310+
runs-on: windows-11-arm
287311
if: |
288312
github.event_name != 'pull_request' ||
289313
github.event.pull_request.author_association == 'COLLABORATOR' ||
@@ -294,10 +318,17 @@ jobs:
294318
test-built-windows-wheel:
295319
name: Test Windows built wheel
296320
needs: build-windows-wheel
297-
runs-on: windows-latest
321+
runs-on: ${{ matrix.runs-on }}
298322
strategy:
323+
fail-fast: false
299324
matrix:
300-
target: [x64]
325+
include:
326+
- target: x64
327+
runs-on: windows-latest
328+
python-version: "3.10"
329+
- target: arm64
330+
runs-on: windows-11-arm
331+
python-version: "3.11" # win-arm runner needs 3.11 atleast
301332
if: |
302333
github.event_name != 'pull_request' ||
303334
github.event.pull_request.author_association == 'COLLABORATOR' ||
@@ -312,7 +343,7 @@ jobs:
312343
- name: Set up Python
313344
uses: actions/setup-python@v5
314345
with:
315-
python-version: "3.10"
346+
python-version: ${{ matrix.python-version }}
316347
cache: "pip"
317348

318349
- name: Download wheel artifacts
@@ -321,6 +352,16 @@ jobs:
321352
name: wheels-windows-${{ matrix.target }}
322353
path: dist
323354

355+
- name: Install ARM64 OpenSSL via vcpkg (Windows ARM64)
356+
if: matrix.runs-on == 'windows-11-arm'
357+
shell: pwsh
358+
run: |
359+
# Static linking avoids runtime DLL load issues.
360+
& "$env:VCPKG_INSTALLATION_ROOT\vcpkg.exe" install openssl:arm64-windows-static-md
361+
$vcpkgRoot = "$env:VCPKG_INSTALLATION_ROOT\installed\arm64-windows-static-md"
362+
echo "OPENSSL_DIR=$vcpkgRoot" >> $env:GITHUB_ENV
363+
echo "OPENSSL_STATIC=1" >> $env:GITHUB_ENV
364+
324365
- name: Create and activate virtual environment
325366
run: |
326367
python -m venv venv
@@ -332,15 +373,7 @@ jobs:
332373
$wheel = Get-ChildItem -Path dist -Filter "c2pa_python-*.whl" | Select-Object -First 1
333374
if (-not $wheel) { Write-Error "No wheel file found in dist directory"; exit 1 }
334375
pip install $wheel.FullName
335-
336-
- name: Run unittest tests on installed wheel
337-
run: |
338-
.\venv\Scripts\activate
339-
python .\tests\test_unit_tests.py
340-
341-
- name: Install pytest (in venv)
342-
run: |
343-
.\venv\Scripts\activate
376+
pip install -r requirements.txt
344377
pip install pytest
345378
346379
- name: Run tests with pytest (venv)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "c2pa-python"
7-
version = "0.32.14"
7+
version = "0.33.0"
88
requires-python = ">=3.10"
99
description = "Python bindings for the C2PA Content Authenticity Initiative (CAI) library"
1010
readme = { file = "README.md", content-type = "text/markdown" }

scripts/download_artifacts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def get_platform_identifier(target_arch=None):
9191
else:
9292
return "universal-apple-darwin"
9393
elif system == "windows":
94-
if target_arch == "arm64":
94+
if target_arch == "arm64" or machine in ["arm64", "aarch64"]:
9595
return "aarch64-pc-windows-msvc"
9696
else:
9797
return "x86_64-pc-windows-msvc"

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def get_version():
4141
'aarch64-apple-darwin': 'dylib',
4242
'x86_64-apple-darwin': 'dylib',
4343
'x86_64-pc-windows-msvc': 'dll',
44+
'aarch64-pc-windows-msvc': 'dll',
4445
'x86_64-unknown-linux-gnu': 'so',
4546
'aarch64-unknown-linux-gnu': 'so',
4647
}
@@ -78,7 +79,7 @@ def get_platform_identifier(target_arch=None) -> str:
7879
else:
7980
return "universal-apple-darwin"
8081
elif system == "windows":
81-
if target_arch == "arm64":
82+
if target_arch == "arm64" or platform.machine().lower() in ["arm64", "aarch64"]:
8283
return "aarch64-pc-windows-msvc"
8384
else:
8485
return "x86_64-pc-windows-msvc"

src/c2pa/lib.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def get_platform_identifier() -> str:
3737
- universal-apple-darwin (for Mac universal)
3838
- aarch64-apple-darwin (for Mac ARM64)
3939
- x86_64-apple-darwin (for Mac x86_64)
40-
- x86_64-pc-windows-msvc (for Windows 64-bit)
40+
- x86_64-pc-windows-msvc (for Windows x64)
41+
- aarch64-pc-windows-msvc (for Windows ARM64)
4142
- x86_64-unknown-linux-gnu (for Linux 64-bit)
4243
- aarch64-unknown-linux-gnu (for Linux ARM)
4344
"""
@@ -54,6 +55,8 @@ def get_platform_identifier() -> str:
5455
else:
5556
return "universal-apple-darwin"
5657
elif system == "windows":
58+
if _get_architecture() in [CPUArchitecture.ARM64.value, CPUArchitecture.AARCH64.value]:
59+
return "aarch64-pc-windows-msvc"
5760
return "x86_64-pc-windows-msvc"
5861
elif system == "linux":
5962
if _get_architecture() in [CPUArchitecture.ARM64.value, CPUArchitecture.AARCH64.value]:
@@ -81,7 +84,7 @@ def _get_architecture() -> str:
8184
elif sys.platform == "win32":
8285
# win32 will cover all Windows versions
8386
# (the 32 is a historical quirk)
84-
return platform.machine()
87+
return platform.machine().lower()
8588
else:
8689
raise RuntimeError(f"Unsupported platform: {sys.platform}")
8790

0 commit comments

Comments
 (0)