-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibzedmd-python-pybind11-extension.yml
More file actions
241 lines (221 loc) · 10.5 KB
/
libzedmd-python-pybind11-extension.yml
File metadata and controls
241 lines (221 loc) · 10.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
name: libzedmd-python-pybind11-extension
run-name: ${{ github.actor }} is building on all platform 🚀
on: [workflow_dispatch]
defaults:
run:
shell: bash
jobs:
version:
name: Detect libzedmd version
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- id: version
working-directory: extern/libzedmd/
run: |
VERSION_MAJOR=$(grep -Eo "ZEDMD_VERSION_MAJOR\s+[0-9]+" src/ZeDMD.h | grep -Eo "[0-9]+")
VERSION_MINOR=$(grep -Eo "ZEDMD_VERSION_MINOR\s+[0-9]+" src/ZeDMD.h | grep -Eo "[0-9]+")
VERSION_PATCH=$(grep -Eo "ZEDMD_VERSION_PATCH\s+[0-9]+" src/ZeDMD.h | grep -Eo "[0-9]+")
TAG="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
echo "${TAG}"
echo "tag=${TAG}" >> $GITHUB_OUTPUT
build:
name: Build libzedmd-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.type }}
runs-on: ${{ matrix.os }}
needs: [ version ]
strategy:
fail-fast: false
matrix:
include:
- { os: windows-latest, platform: win, arch: x64, type: Release }
- { os: macos-latest, platform: macos, arch: arm64, type: Release }
- { os: macos-13, platform: macos, arch: x64, type: Release }
- { os: ubuntu-latest, platform: linux, arch: x64, type: Release }
- { os: ubuntu-24.04-arm, platform: linux, arch: aarch64, type: Release }
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- if: (matrix.platform == 'win') && (matrix.arch == 'x86')
name: Add msbuild x86 to path (win runner)
uses: microsoft/setup-msbuild@v2
with:
msbuild-architecture: x86
- if: (matrix.platform == 'win') && (matrix.arch == 'x64')
name: Add msbuild x64 to path (win runner)
uses: microsoft/setup-msbuild@v2
with:
msbuild-architecture: x64
- if: (matrix.arch == 'x86')
name: Set up Python x86
uses: actions/setup-python@v5
with:
architecture: 'x86'
python-version: 3.12.4
- if: (matrix.arch == 'x64') || (matrix.arch == 'arm64')
name: Set up Python x64
uses: actions/setup-python@v5
with:
architecture: 'x64'
python-version: 3.12.4
- if: (matrix.platform == 'macos')
name: Add autoconf and automake (mac runner)
run: |
brew install autoconf automake libtool
- name: Which python
run: which -a python
- name: Build libzedmd-${{ matrix.platform }}-${{ matrix.arch }}
working-directory: extern/libzedmd/
run: |
./platforms/${{ matrix.platform }}/${{ matrix.arch }}/external.sh
if [[ "${{ matrix.platform }}" == "win" ]]; then
if [[ "${{ matrix.arch }}" == "x64" ]]; then
cmake -G "Visual Studio 17 2022" -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build
elif [[ "${{ matrix.arch }}" == "x86" ]]; then
cmake -G "Visual Studio 17 2022" -A Win32 -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build
elif [[ "${{ matrix.arch }}" == "arm64" ]]; then
cmake -G "Visual Studio 17 2022" -A ARM64 -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build
fi
cmake --build build --config ${{ matrix.type }}
else
if [[ "$(uname)" == "Darwin" ]]; then
NUM_PROCS=$(sysctl -n hw.ncpu)
else
NUM_PROCS=$(nproc)
fi
cmake -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -B build
cmake --build build -- -j${NUM_PROCS}
fi
- name: Install pybind11
run: |
pip install pybind11
python --version
pip --version
python -c "import pybind11; print(pybind11.__version__)"
cmake --version
python -c "import platform; print(platform.uname())"
- name: Setting var PYBIND11_DIR
run: echo "PYBIND11_DIR=$(python -c 'import pybind11; print(pybind11.get_cmake_dir())')" >> $GITHUB_ENV
- name: Testing PYBIND11_DIR
run: echo "PYBIND11_DIR=${{ env.PYBIND11_DIR }}"
- name: Build libzedmd-python-python-extension
run: |
mkdir build
cd build
ls ../extern/libzedmd/build
echo '--------------------------------------'
rm -Rf ./*
if [[ "${{ matrix.platform }}" == "win" ]]; then
if [[ "${{ matrix.arch }}" == "x64" ]]; then
cmake -G "Visual Studio 17 2022" -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -Dpybind11_DIR=${{ env.PYBIND11_DIR }} ..
elif [[ "${{ matrix.arch }}" == "x86" ]]; then
cmake -G "Visual Studio 17 2022" -A Win32 -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -Dpybind11_DIR=${{ env.PYBIND11_DIR }} ..
fi
cmake --build . --config ${{ matrix.type }}
else
if [[ "$(uname)" == "Darwin" ]]; then
NUM_PROCS=$(sysctl -n hw.ncpu)
else
NUM_PROCS=$(nproc)
fi
cmake -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DPLATFORM=${{ matrix.platform }} -DARCH=${{ matrix.arch }} -Dpybind11_DIR=${{ env.PYBIND11_DIR }} ..
cmake --build . -- -j${NUM_PROCS}
fi
- name: List files in builds
working-directory: build/
run: |
ls -R
echo '-----------------------------------'
ls -R ../extern/libzedmd/build
- name: Test extending
run: |
pip install numpy
pip install pillow
python extending.py
- name: Prepare artifacts
id: artifacts
run: |
mkdir tmp
if [[ "${{ matrix.platform }}" == "win" ]]; then
ARTIFACT_PATH="tmp"
if [[ "${{ matrix.arch }}" == "x64" ]]; then
cp extern/libzedmd/build/${{ matrix.type }}/zedmd64.dll tmp
cp extern/libzedmd/build/${{ matrix.type }}/libserialport64.dll tmp
cp extern/libzedmd/build/${{ matrix.type }}/sockpp64.dll tmp
elif [[ "${{ matrix.arch }}" == "x86" ]]; then
cp extern/libzedmd/build/${{ matrix.type }}/zedmd.dll tmp
cp extern/libzedmd/build/${{ matrix.type }}/libserialport.dll tmp
cp extern/libzedmd/build/${{ matrix.type }}/sockpp.dll tmp
fi
cp build/${{ matrix.type }}/extending.pyd tmp
else
ARTIFACT_PATH="libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz"
cp extern/libzedmd/build/libzedmd.* tmp
cp extern/libzedmd/build/libserialport.* tmp
cp extern/libzedmd/build/libsockpp.* tmp
cp build/extending.so tmp
cd tmp
tar -czvf ../${ARTIFACT_PATH} *
fi
echo "artifact_path=${ARTIFACT_PATH}" >> $GITHUB_OUTPUT
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.type }}
path: ${{ steps.artifacts.outputs.artifact_path }}
post-build:
runs-on: macos-latest
needs: [ version, build ]
name: Build libzedmd-macos
steps:
- uses: actions/download-artifact@v4
- name: Unpack artifacts
run: |
cd libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-x64-Release
tar -xzvf libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-x64.tar.gz
cd ..
cd libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-arm64-Release
tar -xzvf libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-arm64.tar.gz
- name: Combine macos architectures
run: |
mkdir tmp
find "libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-arm64-Release" -name "*.dylib" | while read -r file; do
if [ -L "$file" ]; then
cp -a "$file" "tmp/"
elif [ -f "$file" ]; then
filename=$(basename "$file")
lipo -create -output "tmp/$filename" \
"libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-arm64-Release/$filename" \
"libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-x64-Release/$filename"
fi
done
- name: Prepare artifacts
run: |
cd tmp
tar -czvf ../libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos.tar.gz *
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-Release
path: libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos.tar.gz
- name: Package
# if: startsWith(github.ref, 'refs/tags/v')
run: |
zip -r libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-win-x64.zip libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-win-x64-Release
- name: Release
uses: softprops/action-gh-release@v2
# if: startsWith(github.ref, 'refs/tags/v')
with:
draft: true
files: |
libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-win-x64.zip
libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-arm64-Release/libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-arm64.tar.gz
libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-x64-Release/libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos-x64.tar.gz
libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-macos.tar.gz
libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-linux-x64-Release/libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-linux-x64.tar.gz
libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-linux-aarch64-Release/libzedmd-python-pybind11-extension-${{ needs.version.outputs.tag }}-linux-aarch64.tar.gz