Skip to content

Build PyMEOS CFFI

Build PyMEOS CFFI #2

name: Build PyMEOS CFFI
on:
create:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
jobs:
build_sdist:
name: Build PyMEOS CFFI source distribution
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: 3.8
cache: "pip"
- name: Setup pip
run: |
python -m pip install --upgrade pip
python -m pip install build
- name: Build sdist
run: |
python -m build -s
ls -l dist
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: pymeos_cffi-sdist
path: ./dist/pymeos_cffi-*.tar.gz
build_wheels:
name: Build PyMEOS CFFI for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-13, macos-14 ]
include:
- ld_prefix: "/usr/local"
- os: macos-14
ld_prefix: "/opt/homebrew"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update brew
if: matrix.os == 'macos-13'
# Necessary to avoid issue with macOS runners. See
# https://github.com/actions/runner-images/issues/4020
run: |
brew reinstall [email protected] || brew link --overwrite [email protected]
brew reinstall [email protected] || brew link --overwrite [email protected]
brew update
- name: Get dependencies from homebrew (cache)
uses: tecolicom/actions-use-homebrew-tools@v1
if: runner.os == 'macOS'
with:
tools: cmake libpq proj json-c gsl geos
- name: Get PROJ version
id: proj_version
if: runner.os == 'macOS'
run: |
proj_version=$(brew list --versions proj)
proj_version=${proj_version#* }
echo "proj_version=$proj_version" >> $GITHUB_OUTPUT
- name: Install MEOS
if: runner.os == 'macOS'
run: |
git clone --depth 1 https://github.com/MobilityDB/MobilityDB
mkdir MobilityDB/build
cd MobilityDB/build
cmake .. -DMEOS=on
make -j
sudo make install
- name: Setup Python
uses: actions/setup-python@v5
with:
cache: "pip"
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.17.0
- name: Set PROJ_DATA (macOS)
if: runner.os == 'macOS'
run: |
PROJ_DATA=${{ matrix.ld_prefix }}/Cellar/proj/${{ steps.proj_version.outputs.proj_version }}/share/proj
echo "PROJ_DATA=$PROJ_DATA" >> $GITHUB_ENV
- name: Set PROJ_DATA and JSON-C path (Linux)
if: runner.os == 'Linux'
run: |
PROJ_DATA=/usr/proj81/share/proj
echo "PROJ_DATA=$PROJ_DATA" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib64" >> $GITHUB_ENV
- name: Build wheels
run: |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${{ matrix.ld_prefix }}/lib
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${{ matrix.ld_prefix }}/lib
export PACKAGE_DATA=1
python -m cibuildwheel --output-dir wheelhouse
env:
# Disable PyPy builds
# Disable builds on musllinux
# Disable builds in linux architectures other than x86_64
CIBW_SKIP: "pp* *musllinux*"
CIBW_ARCHS_LINUX: "x86_64"
CIBW_ENVIRONMENT_PASS_LINUX: PACKAGE_DATA LD_LIBRARY_PATH PROJ_DATA
CIBW_BEFORE_ALL_LINUX: >
yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm &&
yum -y update &&
yum -y install gcc gcc-c++ make cmake postgresql13-devel proj81-devel geos39-devel gsl-devel &&
git clone --branch json-c-0.17 --depth 1 https://github.com/json-c/json-c &&
mkdir json-c-build &&
cd json-c-build &&
cmake ../json-c &&
make &&
make install &&
git clone --depth 1 https://github.com/MobilityDB/MobilityDB &&
mkdir MobilityDB/build &&
cd MobilityDB/build &&
cmake .. -DMEOS=on -DGEOS_INCLUDE_DIR=/usr/geos39/include/ -DGEOS_LIBRARY=/usr/geos39/lib64/libgeos_c.so -DGEOS_CONFIG=/usr/geos39/bin/geos-config -DPROJ_INCLUDE_DIRS=/usr/proj81/include/ -DPROJ_LIBRARIES=/usr/proj81/lib/libproj.so &&
make -j &&
make install
# Skip tests since they will be tested in the next job
CIBW_TEST_SKIP: "*"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: pymeos_cffi-wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl
test_wheels:
name: Test PyMEOS CFFI wheel - Python ${{ matrix.python-version }} on ${{ matrix.os }}
needs: build_wheels
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
os: [ ubuntu-latest, macos-13, macos-14 ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download wheels
uses: actions/download-artifact@v4
with:
name: pymeos_cffi-wheels-${{ matrix.os }}
path: ./pymeos_cffi_wheels
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install PyMEOS-CFFI wheels
run: |
python -m pip install --upgrade pip
pip install -f ./pymeos_cffi_wheels pymeos_cffi
- name: Run PyMEOS-CFFI check
run: |
python -c "import pymeos_cffi; print(pymeos_cffi.__version__);"
python -c "from pymeos_cffi import *; meos_initialize(None); print(tpoint_out(tgeompoint_in('POINT(2 3)@2000-01-01'), 3)); meos_finalize();"
upload_pypi:
name: Upload to PyPI
needs: [ test_wheels, build_sdist ]
runs-on: ubuntu-22.04
if: github.repository == 'MobilityDB/PyMEOS-CFFI'
permissions:
id-token: write
steps:
- name: Get artifacts
uses: actions/download-artifact@v4
with:
path: ./dist
merge-multiple: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip_existing: true
create_release:
name: Create GitHub Release
needs: [ test_wheels, build_sdist ]
runs-on: ubuntu-22.04
steps:
- name: Get artifacts
uses: actions/download-artifact@v4
with:
path: ./dist
merge-multiple: true
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: ./dist/*