Merge branch 'dev' #155
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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.27.7] | |
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.27.7] | |
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: | | |
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.27.7] | |
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 |