Build pye3d #463
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
# This is a basic workflow that is manually triggered | |
name: Build pye3d | |
on: | |
pull_request: | |
push: | |
tags: | |
- "**" | |
schedule: | |
# run every 6 days to keep cache alive | |
- cron: "30 7 */6 * *" | |
workflow_dispatch: | |
inputs: | |
should_invalidate_cache_download: | |
description: "Fill to invalidate download cache" | |
default: "" | |
required: false | |
should_invalidate_cache_build: | |
description: "Fill to invalidate build cache" | |
default: "" | |
required: false | |
env: | |
eigen-download-url: "https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.zip" | |
eigen-install-dir: ${{ github.workspace }}/eigen-build | |
eigen-install-dir-manylinux: /pye3d-deps/eigen | |
pye3d-test-input-download-url: "https://github.com/pupil-labs/pye3d-detector/wiki/files/pye3d_test_input.npz" | |
jobs: | |
build_eigen_manylinux: | |
name: Build Eigen on manylinux | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
runs-on: ${{ matrix.os }} | |
container: | |
image: quay.io/pypa/manylinux2014_x86_64 | |
env: | |
eigen-install-dir-manylinux: /pye3d-deps/eigen | |
steps: | |
- name: Cache Eigen source code download | |
id: eigen-source-cache | |
uses: actions/[email protected] | |
with: | |
path: eigen.zip | |
key: eigen-source-cache-${{ env.eigen-download-url }} | |
- name: Download on manylinux | |
if: (github.event.inputs.should_invalidate_cache_download || steps.eigen-source-cache.outputs.cache-hit != 'true') | |
run: curl -L ${{ env.eigen-download-url }} --output eigen.zip --silent | |
- name: Cache eigen build | |
id: eigen-build-cache | |
uses: actions/[email protected] | |
with: | |
path: ${{ env.eigen-install-dir-manylinux }} | |
key: eigen-build-cache-${{ matrix.os }}-${{ env.eigen-download-url }} | |
- name: Prepare build | |
shell: bash | |
run: | | |
set -xe | |
unzip -q eigen.zip | |
mv eigen-3.* eigen/ | |
mkdir eigen/build | |
- name: Configure build | |
if: github.event.inputs.should_invalidate_cache_build || steps.eigen-build-cache.outputs.cache-hit != 'true' | |
working-directory: eigen/build | |
shell: bash | |
run: cmake .. -DCMAKE_INSTALL_PREFIX="${{ env.eigen-install-dir-manylinux }}" | |
- name: Compile on manylinux | |
if: (github.event.inputs.should_invalidate_cache_build || steps.eigen-build-cache.outputs.cache-hit != 'true') | |
working-directory: eigen/build | |
run: | | |
make | |
make install | |
- name: Upload build as artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: build-${{ matrix.os }} | |
path: ${{ env.eigen-install-dir-manylinux }} | |
build_eigen_macos_windows: | |
name: Build Eigen on ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [macos-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
continue-on-error: false | |
steps: | |
- name: Cache Eigen source code download | |
id: eigen-source-cache | |
uses: actions/[email protected] | |
with: | |
path: eigen.zip | |
key: eigen-source-cache-${{ env.eigen-download-url }} | |
- name: Download on Unix | |
if: (github.event.inputs.should_invalidate_cache_download || steps.eigen-source-cache.outputs.cache-hit != 'true') && !contains(runner.os, 'windows') | |
run: wget -q -O eigen.zip ${{ env.eigen-download-url }} | |
- name: Download on Windows | |
if: (github.event.inputs.should_invalidate_cache_download || steps.eigen-source-cache.outputs.cache-hit != 'true') && contains(runner.os, 'windows') | |
run: Invoke-WebRequest ${{ env.eigen-download-url }} -OutFile eigen.zip | |
- name: Cache eigen build | |
id: eigen-build-cache | |
uses: actions/[email protected] | |
with: | |
path: ${{ env.eigen-install-dir }} | |
key: eigen-build-cache-${{ matrix.os }}-${{ env.eigen-download-url }} | |
- name: Prepare build | |
shell: bash | |
run: | | |
set -xe | |
unzip -q eigen.zip | |
mv eigen-3.* eigen/ | |
mkdir eigen/build | |
- name: Configure build | |
if: github.event.inputs.should_invalidate_cache_build || steps.eigen-build-cache.outputs.cache-hit != 'true' | |
working-directory: eigen/build | |
shell: bash | |
run: cmake .. -DCMAKE_INSTALL_PREFIX="${{ env.eigen-install-dir }}" | |
- name: Compile on Windows | |
if: runner.os == 'Windows' && (github.event.inputs.should_invalidate_cache_build || steps.eigen-build-cache.outputs.cache-hit != 'true') | |
working-directory: eigen/build | |
run: cmake --build . --target INSTALL --config Release --parallel | |
- name: Compile on macOS | |
if: runner.os != 'Windows' && (github.event.inputs.should_invalidate_cache_build || steps.eigen-build-cache.outputs.cache-hit != 'true') | |
working-directory: eigen/build | |
run: | | |
make | |
make install | |
- name: Upload build as artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: build-${{ matrix.os }} | |
path: ${{ env.eigen-install-dir }} | |
build_wheels: | |
name: "Build pye3d wheels on ${{ matrix.os }}" | |
if: github.event_name != 'schedule' | |
needs: | |
- build_eigen_macos_windows | |
- build_eigen_manylinux | |
strategy: | |
matrix: | |
os: [windows-latest, ubuntu-latest, macos-latest] | |
continue-on-error: true | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Dump GitHub context | |
env: | |
GITHUB_CONTEXT: ${{ toJSON(github) }} | |
run: echo "$GITHUB_CONTEXT" | |
- uses: actions/checkout@v2 | |
- name: Download build as artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: build-${{ matrix.os }} | |
- name: Dump file list | |
shell: bash | |
run: ls -laR | |
- name: Build wheels | |
uses: pypa/[email protected] | |
env: | |
Eigen3_DIR: ${{ github.workspace }} | |
CIBW_ENVIRONMENT_LINUX: > | |
LD_LIBRARY_PATH=/project/lib64:$LD_LIBRARY_PATH | |
Eigen3_DIR=/project | |
CIBW_SKIP: "cp27-* cp35-* pp* *win32 *_aarch64 *_ppc64le *_s390x *_i686 *musllinux*" | |
CIBW_ARCHS_MACOS: "x86_64" | |
CIBW_ARCHS_LINUX: "x86_64" | |
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 | |
CIBW_BEFORE_BUILD_WINDOWS: pip install delvewheel | |
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: python scripts\repair_wheels_windows.py {wheel} {dest_dir} | |
CIBW_TEST_REQUIRES: pytest opencv-python==4.6.0.66 pandas scikit-image matplotlib | |
CIBW_TEST_COMMAND: > | |
curl -L ${{ env.pye3d-test-input-download-url }} --silent | |
--output {package}/tests/integration/input/pye3d_test_input.npz | |
&& pytest {package}/tests | |
CIBW_TEST_COMMAND_WINDOWS: > | |
curl -L ${{ env.pye3d-test-input-download-url }} --silent | |
--output {package}\tests\integration\input\pye3d_test_input.npz | |
&& pytest {package}\tests | |
CIBW_TEST_SKIP: "*-macosx_arm64 *-macosx_universal2:arm64" | |
- uses: actions/upload-artifact@v2 | |
if: always() | |
with: | |
name: distribution | |
path: ./wheelhouse/*.whl | |
build_sdist: | |
name: Build source distribution | |
if: github.event_name != 'schedule' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-python@v1 | |
with: | |
python-version: 3.7 | |
- name: Build source package | |
run: | | |
pip install build | |
python -m build --sdist . | |
- name: Upload source package | |
uses: actions/upload-artifact@v2 | |
with: | |
name: distribution | |
path: dist/ | |
build_docs: | |
name: Ensure documentation builds correctly | |
if: github.event_name != 'schedule' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-python@v1 | |
with: | |
python-version: 3.9 | |
- name: Build docs via tox | |
run: | | |
pip install tox | |
tox -e docs | |
publish: | |
runs-on: ubuntu-latest | |
needs: [build_wheels, build_sdist, build_docs] | |
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/') | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/download-artifact@v2 | |
with: | |
name: distribution | |
path: dist/ | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@master | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_TOKEN }} |