Skip to content

MNT: Upgrade Maplibre to latest #97

MNT: Upgrade Maplibre to latest

MNT: Upgrade Maplibre to latest #97

Workflow file for this run

name: Build wheels
on:
push:
paths:
- ".github/workflows/build_wheels.yml"
- "MANIFEST.in"
- "pyproject.toml"
- "setup.py"
branches:
- main
tags:
- "v*"
pull_request:
paths:
- ".github/workflows/build_wheels.yml"
- "MANIFEST.in"
- "pyproject.toml"
- "setup.py"
workflow_dispatch:
env:
BUILD_TEMP_DIR: "build"
MACOSX_DEPLOYMENT_TARGET: "12"
jobs:
build_wheels:
name: BLD ${{ matrix.os }} ${{ matrix.platform }} (Python ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- "ubuntu-24.04"
- "ubuntu-22.04"
- "ubuntu-20.04"
- "macos-14"
include:
- os: "ubuntu-24.04"
platform: "x86_64"
wheel: pymgl-wheel-ubuntu-24.04-x86_64
- os: "ubuntu-22.04"
platform: "x86_64"
wheel: pymgl-wheel-ubuntu-22.04-x86_64
- os: "ubuntu-20.04"
platform: "x86_64"
wheel: pymgl-wheel-ubuntu-20.04-x86_64
- os: "macos-14"
platform: "arm64"
wheel: pymgl-wheel-macos-arm64
- os: "macos-13"
platform: "x86_64"
wheel: pymgl-wheel-macos-x86_64
python-version: ["3.9", "3.10", "3.11", "3.12"]
env:
PLATFORM_OS: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout submodules
run: |
git submodule update --init
cd vendor/nanobind && \
git submodule update --init --recursive
cd ../maplibre-native && \
git submodule update --init --recursive \
vendor/boost \
vendor/cpp-httplib \
vendor/earcut.hpp \
vendor/eternal \
vendor/googletest \
vendor/polylabel \
vendor/protozero \
vendor/mapbox-base \
vendor/unique_resource \
vendor/unordered_dense \
vendor/vector-tile \
vendor/wagyu \
vendor/zip-archive
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get -y install software-properties-common
sudo add-apt-repository -y ppa:deadsnakes/ppa
sudo apt-get -y install \
curl \
build-essential \
cmake \
ccache \
pkg-config \
libcurl4-openssl-dev \
libicu-dev \
libjpeg-turbo8-dev \
libpng-dev \
libwebp-dev \
libprotobuf-dev \
libuv1-dev \
libx11-dev \
libegl-dev \
libopengl-dev \
libgles2-mesa-dev \
xvfb
sudo /usr/sbin/update-ccache-symlinks
- name: fix Ubuntu 20.04 GCC
if: ${{ matrix.os == 'ubuntu-20.04' }}
run: |
sudo add-apt-repository --update -y ppa:ubuntu-toolchain-r/test && \
sudo apt-get -y --fix-broken install gcc-11 g++-11
- name: Install MacOS dependencies
if: runner.os == 'macOS'
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
run: |
brew install ccache
- name: Install python & dependencies
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh && \
. $HOME/.cargo/env && \
uv python install ${{ matrix.python-version }} && \
uv venv .venv
echo "VIRTUAL_ENV=.venv" >> $GITHUB_ENV
echo "$PWD/.venv/bin" >> $GITHUB_PATH
uv pip install versioneer[toml]==0.29 tomli setuptools ninja
- name: Prepare ccache
run: ccache --clear --set-config cache_dir=~/.ccache
- name: Cache ccache
uses: actions/cache@v4
env:
cache-name: ccache-v1
with:
path: ~/.ccache
key: ${{ env.cache-name }}-${{ matrix.os }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}-${{ github.head_ref }}
restore-keys: |
${{ env.cache-name }}-${{ matrix.os }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}
${{ env.cache-name }}-${{ matrix.os }}-${{ github.job }}-${{ github.ref }}
${{ env.cache-name }}-${{ matrix.os }}-${{ github.job }}
- name: Clear ccache statistics
run: |
ccache --zero-stats --set-config cache_dir=~/.ccache
ccache --max-size=2G --set-config cache_dir=~/.ccache
ccache --show-stats --set-config cache_dir=~/.ccache
- name: Set platform tag for Ubuntu 24.04
if: matrix.os == 'ubuntu-24.04'
run: echo "PLATFORM_TAG=ubuntu24_04_x86_64" >> $GITHUB_ENV
- name: Set platform tag for Ubuntu 22.04
if: matrix.os == 'ubuntu-22.04'
run: echo "PLATFORM_TAG=ubuntu22_04_x86_64" >> $GITHUB_ENV
- name: Set platform tag for Ubuntu 20.04
if: matrix.os == 'ubuntu-20.04'
run: echo "PLATFORM_TAG=ubuntu20_04_x86_64">> $GITHUB_ENV
- name: Build package for Ubuntu
if: runner.os == 'Linux'
env:
CMAKE_CXX_COMPILER_LAUNCHER: ccache
run: |
sudo mkdir -p $BUILD_TEMP_DIR
sudo chown -R $(id -u):$(id -g) $BUILD_TEMP_DIR
uv build --wheel
echo "List wheels"
ls ./dist
find ./dist -type f -name '*.whl' -exec mv {} {}.$PLATFORM_OS \;
echo "Renamed with $PLATFORM_OS suffix"
ls ./dist
- name: Build package for MacOS
if: runner.os == 'macOS'
env:
CMAKE_CXX_COMPILER_LAUNCHER: ccache
run: |
sudo mkdir -p $BUILD_TEMP_DIR
sudo chown -R $(id -u):$(id -g) $BUILD_TEMP_DIR
uv build --wheel
- name: "Upload artifacts"
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.wheel }}-${{ matrix.python-version }}
path: ./dist/*
test-wheels:
name: TST ${{ matrix.os }} ${{ matrix.platform }} (Python ${{ matrix.python-version }})
needs: [build_wheels]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- "ubuntu-24.04"
- "ubuntu-22.04"
- "ubuntu-20.04"
- "macos-14"
- "macos-13"
- "macos-12"
include:
- os: "ubuntu-24.04"
platform: "x86_64"
wheel: pymgl-wheel-ubuntu-24.04-x86_64
- os: "ubuntu-22.04"
platform: "x86_64"
wheel: pymgl-wheel-ubuntu-22.04-x86_64
- os: "ubuntu-20.04"
platform: "x86_64"
wheel: pymgl-wheel-ubuntu-20.04-x86_64
- os: "macos-14"
platform: "arm64"
wheel: pymgl-wheel-macos-arm64
- os: "macos-13"
platform: "x86_64"
wheel: pymgl-wheel-macos-x86_64
- os: "macos-12"
platform: "x86_64"
wheel: pymgl-wheel-macos-x86_64
python-version: ["3.9", "3.10", "3.11", "3.12"]
env:
PLATFORM_OS: ${{ matrix.os }}
LIBGL_ALWAYS_SOFTWARE: 1
steps:
- name: Download wheels from artifacts
uses: actions/download-artifact@v4
with:
pattern: ${{ matrix.wheel }}-${{ matrix.python-version }}
path: wheelhouse
merge-multiple: true
- name: Install Ubuntu 24.04 runtime dependencies
if: matrix.os == 'ubuntu-24.04'
run: |
sudo apt-get update
sudo apt-get -y install \
libicu74 \
libcurl4 \
libjpeg-turbo8 \
libpng16-16 \
libwebp7 \
libprotobuf32 \
libuv1 \
libx11-6 \
libegl1 \
libopengl0 \
libgles2 \
xvfb && \
# upgrade Mesa packages
sudo apt-get install -y software-properties-common && \
sudo add-apt-repository -y ppa:kisak/kisak-mesa && \
sudo apt-get update && \
sudo apt-get install -y libglx-mesa0
- name: Install Ubuntu 22.04 runtime dependencies
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get -y install \
libicu70 \
libcurl4 \
libjpeg-turbo8 \
libpng16-16 \
libwebp7 \
libprotobuf23 \
libuv1 \
libx11-6 \
libegl1 \
libopengl0 \
libgles2 \
xvfb
- name: Install Ubuntu 20.04 runtime dependencies
if: matrix.os == 'ubuntu-20.04'
run: |
sudo apt-get update
sudo apt-get -y install \
libicu66 \
libcurl4 \
libjpeg-turbo8 \
libpng16-16 \
libwebp6 \
libprotobuf17 \
libuv1 \
libx11-6 \
libegl1 \
libopengl0 \
libgles2 \
xvfb
- name: Install python & dependencies
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh && \
. $HOME/.cargo/env && \
uv python install ${{ matrix.python-version }} && \
uv venv .venv
echo "VIRTUAL_ENV=.venv" >> $GITHUB_ENV
echo "$PWD/.venv/bin" >> $GITHUB_PATH
uv pip install pytest Pillow numpy pixelmatch python-dotenv
- name: Install and test wheels on Ubuntu
if: runner.os == 'Linux'
run: |
find ./wheelhouse -type f -name "*.whl.$PLATFORM_OS" -print0 -exec bash -c 'mv "${0}" "${0//.$PLATFORM_OS/}"' {} \;
uv pip install --no-cache --pre --no-index --find-links wheelhouse pymgl
uv pip list
xvfb-run -a --server-args="-screen 0 1024x768x24 -ac +render -noreset" pytest --pyargs pymgl -v
- name: Install and test wheels on MacOS
if: runner.os == 'macOS'
run: |
uv pip install --no-cache --pre --no-index --find-links wheelhouse pymgl
uv pip list
cd ..
pytest --pyargs pymgl -v
# NOTE: publish is limited to MacOS wheels because Linux wheels are not accepted
# for only Ubuntu, must be manylinux
publish:
name: Publish to GitHub / PyPI
needs: [test-wheels]
runs-on: ubuntu-latest
# only publish on tags
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v4
with:
pattern: pymgl-wheel-*
path: wheelhouse
merge-multiple: true
# NOTE: MacOS wheel are the only ones that can be published to PyPI
- name: Copy MacOS wheel
run: |
mkdir wheelhouse/dist
cp wheelhouse/*macos*.whl wheelhouse/dist
- name: Publish MacOS wheel to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: wheelhouse/dist/
- name: Release
uses: softprops/action-gh-release@v2
with:
name: Version ${{ github.ref_name }}
tag_name: ${{ github.ref }}
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
files: |
./wheelhouse/*