1
+ name : Build Wheel
2
+
3
+ on :
4
+ workflow_call :
5
+ inputs :
6
+ python-version :
7
+ required : true
8
+ type : string
9
+ architecture :
10
+ required : false
11
+ type : string
12
+ artifact-name :
13
+ required : true
14
+ type : string
15
+ runs-on :
16
+ required : true
17
+ type : string
18
+ default : ' ubuntu-latest'
19
+ c2pa-version :
20
+ required : true
21
+ type : string
22
+ secrets :
23
+ github-token :
24
+ required : true
25
+
26
+ permissions :
27
+ contents : read
28
+ packages : read
29
+ actions : read
30
+
31
+ env :
32
+ GITHUB_TOKEN : ${{ secrets.github-token }}
33
+ C2PA_VERSION : ${{ inputs.c2pa-version }}
34
+
35
+ jobs :
36
+ build :
37
+ runs-on : ${{ inputs.runs-on }}
38
+ steps :
39
+ - uses : actions/checkout@v4
40
+
41
+ - name : Build Linux wheels
42
+ if : runner.os == 'Linux'
43
+ run : |
44
+ # Create necessary directories
45
+ mkdir -p artifacts
46
+ mkdir -p src/c2pa/libs
47
+ rm -rf dist build
48
+
49
+ # Set Docker image and platform tag based on architecture
50
+ if [ "${{ inputs.architecture }}" = "aarch64" ]; then
51
+ DOCKER_IMAGE="quay.io/pypa/manylinux_2_28_aarch64"
52
+ PLATFORM_TAG="manylinux_2_28_aarch64"
53
+ else
54
+ DOCKER_IMAGE="quay.io/pypa/manylinux_2_28_x86_64"
55
+ PLATFORM_TAG="manylinux_2_28_x86_64"
56
+ fi
57
+
58
+ # Build wheel in Docker container
59
+ docker run --rm -v $PWD:/io $DOCKER_IMAGE bash -c "
60
+ yum install -y gcc gcc-c++ make &&
61
+ mkdir -p /io/artifacts /io/src/c2pa/libs &&
62
+ rm -rf /io/dist /io/build &&
63
+ cd /io &&
64
+ /opt/python/cp310-cp310/bin/pip install -r requirements.txt -r requirements-dev.txt &&
65
+ /opt/python/cp310-cp310/bin/pip install toml &&
66
+ C2PA_LIBS_PLATFORM=\"${{ inputs.architecture == 'aarch64' && 'aarch64-unknown-linux-gnu' || 'x86_64-unknown-linux-gnu' }}\" /opt/python/cp310-cp310/bin/python scripts/download_artifacts.py $C2PA_VERSION &&
67
+ for PYBIN in /opt/python/cp3{10,11}-*/bin; do
68
+ \${PYBIN}/pip install --upgrade pip wheel &&
69
+ \${PYBIN}/pip install toml &&
70
+ CFLAGS=\"-I/opt/python/cp310-cp310/include/python3.10\" LDFLAGS=\"-L/opt/python/cp310-cp310/lib\" \${PYBIN}/python setup.py bdist_wheel --plat-name $PLATFORM_TAG
71
+ done &&
72
+ rm -f /io/dist/*-linux_*.whl
73
+ "
74
+
75
+ # Verify the wheel was built
76
+ echo "Contents of dist directory:"
77
+ ls -la dist/
78
+ echo "Number of wheels found:"
79
+ find dist -name "*.whl" | wc -l
80
+ echo "Wheel filenames:"
81
+ find dist -name "*.whl" -exec basename {} \;
82
+
83
+ - name : Build Windows wheel (x64)
84
+ if : runner.os == 'Windows'
85
+ shell : pwsh
86
+ run : |
87
+ # Create necessary directories
88
+ New-Item -ItemType Directory -Force -Path artifacts
89
+ New-Item -ItemType Directory -Force -Path src/c2pa/libs
90
+ if (Test-Path dist) { Remove-Item -Recurse -Force dist }
91
+ if (Test-Path build) { Remove-Item -Recurse -Force build }
92
+
93
+ # Install dependencies
94
+ pip install -r requirements.txt
95
+ pip install -r requirements-dev.txt
96
+ pip install wheel
97
+
98
+ # Download native artifacts
99
+ Write-Host "Starting artifact download process..."
100
+ Write-Host "C2PA_VERSION: $env:C2PA_VERSION"
101
+
102
+ python scripts/download_artifacts.py "$env:C2PA_VERSION"
103
+
104
+ Write-Host "Artifacts directory contents:"
105
+ Get-ChildItem -Recurse -Path artifacts
106
+ Write-Host "src/c2pa/libs directory contents:"
107
+ Get-ChildItem -Recurse -Path src/c2pa/libs
108
+
109
+ # Build wheel
110
+ python setup.py bdist_wheel --plat-name win_amd64
111
+
112
+ - name : Build macOS wheel (Apple Silicon)
113
+ if : runner.os == 'macOS' && runner.arch == 'arm64'
114
+ run : |
115
+ # Create necessary directories
116
+ mkdir -p artifacts
117
+ mkdir -p src/c2pa/libs
118
+ rm -rf dist build
119
+
120
+ # Install dependencies
121
+ pip install -r requirements.txt
122
+ pip install -r requirements-dev.txt
123
+ pip install wheel
124
+
125
+ # Download native artifacts
126
+ python scripts/download_artifacts.py $C2PA_VERSION
127
+
128
+ # Build wheel
129
+ python setup.py bdist_wheel --plat-name macosx_11_0_arm64
130
+
131
+ # Rename wheel to ensure unique filename
132
+ cd dist
133
+ for wheel in *.whl; do
134
+ mv "$wheel" "${wheel/macosx_11_0_arm64/macosx_11_0_arm64}"
135
+ done
136
+ cd ..
137
+
138
+ - name : Log wheel filename
139
+ if : runner.os == 'Linux' || runner.os == 'macOS'
140
+ shell : bash
141
+ run : |
142
+ echo "Built wheel:"
143
+ ls -l dist/*.whl
144
+
145
+ - name : Upload wheels
146
+ uses : actions/upload-artifact@v4
147
+ with :
148
+ name : ${{ inputs.artifact-name }}
149
+ path : dist
150
+ if-no-files-found : error
0 commit comments