-
Notifications
You must be signed in to change notification settings - Fork 39
238 lines (205 loc) · 7.13 KB
/
build.yml
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
# Build pyexiv2 on Linux, MacOS, and Windows. Then test it.
name: Build
on:
push:
branches:
- master
workflow_dispatch:
jobs:
job1:
name: Build on Linux
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
python_version: [3.7, 3.8, 3.9, '3.10', '3.11', '3.12']
exiv2_version: [0.28.1]
runs-on: ${{matrix.os}}
env:
PLATFORM_NAME: linux
EXIV2_URL: https://github.com/Exiv2/exiv2/releases/download/v${{matrix.exiv2_version}}
EXIV2_VERSION: ${{matrix.exiv2_version}}
EXIV2_BUILD_NAME: exiv2-${{matrix.exiv2_version}}-Linux64
EXIV2_BUILD_EXT: .tar.gz
PYTHON_VERSION: ${{matrix.python_version}}
steps:
- name: Set environment variables
run: |
set -u
echo EXIV2_BUILDS_URL=${EXIV2_URL}/${EXIV2_BUILD_NAME}${EXIV2_BUILD_EXT} >> $GITHUB_ENV
echo EXIV2_DIR=`pwd`/${EXIV2_BUILD_NAME} >> $GITHUB_ENV
echo LIB_DIR=`pwd`/pyexiv2/lib >> $GITHUB_ENV
echo SUB_LIB_DIR=`pwd`/pyexiv2/lib/py${PYTHON_VERSION}-${PLATFORM_NAME} >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: Download Exiv2 build
run: |
curl -LO $EXIV2_BUILDS_URL
tar -zxf ${EXIV2_BUILD_NAME}${EXIV2_BUILD_EXT}
cp -f ${EXIV2_DIR}/lib/libexiv2.so.${EXIV2_VERSION} ${LIB_DIR}/libexiv2.so
- name: Set up Python ${{matrix.python_version}}
uses: actions/setup-python@v2
with:
python-version: ${{matrix.python_version}}
- name: Install dependencies
run: |
# apt install python3-dev
python -m pip install pybind11 pytest psutil
- name: Build
run: |
cd $LIB_DIR
rm -rf $SUB_LIB_DIR
mkdir $SUB_LIB_DIR
g++ exiv2api.cpp -o $SUB_LIB_DIR/exiv2api.so \
-O3 -Wall -std=c++11 -shared -fPIC \
`python -m pybind11 --includes` \
-I $EXIV2_DIR/include \
-L $EXIV2_DIR/lib \
-l exiv2
- name: Copy artifact
run: |
cp $SUB_LIB_DIR/exiv2api.so .
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: py${{matrix.python_version}}-${{env.PLATFORM_NAME}}
path: |
exiv2api.so
retention-days: 1
- name: Test
run: |
python -m pytest -v
job2:
name: Build on MacOS
strategy:
fail-fast: false
matrix:
os: [macos-12]
python_version: [3.6, 3.7, 3.8, 3.9, '3.10', '3.11', '3.12']
exiv2_version: [0.28.1]
runs-on: ${{matrix.os}}
env:
PLATFORM_NAME: darwin
EXIV2_URL: https://github.com/Exiv2/exiv2/releases/download/v${{matrix.exiv2_version}}
EXIV2_VERSION: ${{matrix.exiv2_version}}
EXIV2_BUILD_NAME: exiv2-${{matrix.exiv2_version}}-Darwin
EXIV2_BUILD_EXT: .tar.gz
PYTHON_VERSION: ${{matrix.python_version}}
steps:
- name: Set environment variables
run: |
set -u
echo EXIV2_BUILDS_URL=${EXIV2_URL}/${EXIV2_BUILD_NAME}${EXIV2_BUILD_EXT} >> $GITHUB_ENV
echo EXIV2_DIR=`pwd`/${EXIV2_BUILD_NAME} >> $GITHUB_ENV
echo LIB_DIR=`pwd`/pyexiv2/lib >> $GITHUB_ENV
echo SUB_LIB_DIR=`pwd`/pyexiv2/lib/py${PYTHON_VERSION}-${PLATFORM_NAME} >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: Download Exiv2 build
run: |
curl -LO $EXIV2_BUILDS_URL
tar -zxf ${EXIV2_BUILD_NAME}${EXIV2_BUILD_EXT}
cp -f $EXIV2_DIR/lib/libexiv2.${EXIV2_VERSION}.dylib $LIB_DIR/libexiv2.dylib
- name: Set up Python ${{matrix.python_version}}
uses: actions/setup-python@v2
with:
python-version: ${{matrix.python_version}}
- name: Install dependencies
run: |
python -m pip install pybind11 pytest psutil
- name: Build
run: |
cd $LIB_DIR
rm -rf $SUB_LIB_DIR
mkdir $SUB_LIB_DIR
g++ exiv2api.cpp -o $SUB_LIB_DIR/exiv2api.so \
-O3 -Wall -std=c++11 -shared -fPIC \
`python -m pybind11 --includes` \
-I $EXIV2_DIR/include \
-L $EXIV2_DIR/lib \
-l exiv2 \
-undefined dynamic_lookup
- name: Copy artifact
run: |
cp $SUB_LIB_DIR/exiv2api.so .
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: py${{matrix.python_version}}-${{env.PLATFORM_NAME}}
path: |
exiv2api.so
retention-days: 1
- name: Test
run: |
brew install inih
python -m pytest -v
job3:
name: Build on Windows
strategy:
fail-fast: false
matrix:
os: [windows-2019]
python_version: [3.6, 3.7, 3.8, 3.9, '3.10', '3.11', '3.12']
exiv2_version: [0.28.1]
runs-on: ${{matrix.os}}
env:
PLATFORM_NAME: win
EXIV2_URL: https://github.com/Exiv2/exiv2/releases/download/v${{matrix.exiv2_version}}
EXIV2_VERSION: ${{matrix.exiv2_version}}
EXIV2_BUILD_NAME: exiv2-${{matrix.exiv2_version}}-2019msvc64
EXIV2_BUILD_EXT: .zip
PYTHON_VERSION: ${{matrix.python_version}}
steps:
- uses: actions/checkout@v2
- name: Set environment variables
shell: cmd
run: |
echo set EXIV2_BUILDS_URL=%EXIV2_URL%/%EXIV2_BUILD_NAME%%EXIV2_BUILD_EXT%>> env.bat
echo set EXIV2_DIR=%CD%\%EXIV2_BUILD_NAME%>> env.bat
echo set LIB_DIR=%CD%\pyexiv2\lib>> env.bat
echo set SUB_LIB_DIR=%CD%\pyexiv2\lib\py%PYTHON_VERSION%-%PLATFORM_NAME%>> env.bat
- name: Download Exiv2 build
shell: cmd
run: |
call env.bat
curl -LO %EXIV2_BUILDS_URL%
python -m zipfile -e %EXIV2_BUILD_NAME%%EXIV2_BUILD_EXT% .
copy %EXIV2_DIR%\bin\exiv2.dll %LIB_DIR%
- name: Set up Python ${{matrix.python_version}}
uses: actions/setup-python@v2
with:
python-version: ${{matrix.python_version}}
- name: Install dependencies
run: |
python -m pip install pybind11 pytest psutil
- name: Build
shell: cmd
run: |
call env.bat
cd %LIB_DIR%
rmdir /s /q %SUB_LIB_DIR%
mkdir %SUB_LIB_DIR%
python -c "import sys; print(sys.exec_prefix)" > tmp.out
set /p PY_HOME=<tmp.out
del tmp.out
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
cl /MD /LD exiv2api.cpp /EHsc ^
-I %EXIV2_DIR%\include ^
-I %PY_HOME%\include ^
-I %PY_HOME%\Lib\site-packages\pybind11\include ^
/link %EXIV2_DIR%\lib\exiv2.lib ^
%PY_HOME%\libs\python%PYTHON_VERSION:.=%.lib ^
/OUT:%SUB_LIB_DIR%\exiv2api.pyd
- name: Copy artifact
shell: cmd
run: |
call env.bat
copy %SUB_LIB_DIR%\exiv2api.pyd .
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: py${{matrix.python_version}}-${{env.PLATFORM_NAME}}
path: |
exiv2api.pyd
retention-days: 1
- name: Test
run: |
python -m pytest -v