Support building wheels. Move third party pip packages into setup.py #38
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
name: limap | |
on: | |
push: | |
branches: | |
- main | |
- release/* | |
pull_request: | |
types: [ assigned, opened, synchronize, reopened ] | |
release: | |
types: [ published, edited ] | |
jobs: | |
build: | |
name: ${{ matrix.config.os }} ${{ matrix.config.arch }} with Python ${{ matrix.config.python-version }} | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
matrix: | |
config: [ | |
{os: ubuntu-latest, python-version: "3.8"}, | |
{os: ubuntu-latest, python-version: "3.9"}, | |
{os: ubuntu-latest, python-version: "3.10"}, | |
{os: ubuntu-latest, python-version: "3.11"}, | |
{os: ubuntu-latest, python-version: "3.12"}, | |
] | |
env: | |
COMPILER_CACHE_VERSION: 1 | |
COMPILER_CACHE_DIR: ${{ github.workspace }}/compiler-cache | |
CCACHE_DIR: ${{ github.workspace }}/compiler-cache/ccache | |
CCACHE_BASEDIR: ${{ github.workspace }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
id: cache-builds | |
with: | |
key: limap-v${{ env.COMPILER_CACHE_VERSION }}-${{ matrix.config.os }}-${{ matrix.config.arch }}-${{ github.run_id }}-${{ github.run_number }} | |
restore-keys: limap-v${{ env.COMPILER_CACHE_VERSION }}-${{ matrix.config.os }}-${{ matrix.config.arch }} | |
path: ${{ env.COMPILER_CACHE_DIR }} | |
- name: Set env (Linux) | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update && sudo apt-get install -y \ | |
git \ | |
build-essential \ | |
cmake \ | |
ninja-build \ | |
libboost-program-options-dev \ | |
libboost-graph-dev \ | |
libboost-system-dev \ | |
libeigen3-dev \ | |
libceres-dev \ | |
libflann-dev \ | |
libfreeimage-dev \ | |
libmetis-dev \ | |
libgoogle-glog-dev \ | |
libgtest-dev \ | |
libgmock-dev \ | |
libsqlite3-dev \ | |
libglew-dev \ | |
qtbase5-dev \ | |
libqt5opengl5-dev \ | |
libcgal-dev \ | |
libcgal-qt5-dev \ | |
libgl1-mesa-dri \ | |
libunwind-dev \ | |
xvfb | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Python dependencies | |
run: | | |
git submodule update --init --recursive | |
python -m pip install --upgrade pip | |
python -m pip install setuptools | |
- name: Build | |
run: python -m pip install -v . | |
- name: Run Python tests | |
run: python -c "import limap; print(limap.__version__)" | |
- name: Build wheels | |
run: python setup.py bdist_wheel | |
env: | |
CIBW_ARCHS_MACOS: ${{ matrix.config.arch }} | |
- name: Upload wheel files as artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: limap-${{ matrix.config.os }}-${{ matrix.config.arch }}-cp${{ matrix.python-version }} | |
path: dist/*.whl | |
pypi-publish: | |
name: Publish wheels to PyPI | |
needs: build | |
runs-on: ubuntu-latest | |
# We publish the wheel to pypi when a new tag is pushed, | |
# either by creating a new GitHub release or explictly with `git tag` | |
if: ${{ github.event_name == 'release' || startsWith(github.ref, 'refs/tags') }} | |
steps: | |
- name: Download wheels | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./artifacts/ | |
- name: Move wheels | |
run: mkdir ./wheelhouse && mv ./artifacts/**/*.whl ./wheelhouse/ | |
- name: Publish package | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
skip-existing: true | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
packages-dir: ./wheelhouse/ |