Skip to content

Return pixels whose value equals nodata value after scaling #279

Return pixels whose value equals nodata value after scaling

Return pixels whose value equals nodata value after scaling #279

Workflow file for this run

name: Python package build
on:
push:
pull_request:
workflow_dispatch:
inputs:
publish_to_pypi:
description: 'Publish wheels and sdist to PyPI'
required: true
default: 'false'
defaults:
run:
shell: bash -l {0}
jobs:
build:
name: Build ${{ matrix.os }} py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Setup conda
uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
environment-file: .github/python_test_env.yml
- name: Set development version number
run: |
COMMIT_NUM=$(git rev-list $(git describe --tags --abbrev=0).. --count)
echo "${COMMIT_NUM} commits since last tag"
sed -i.old "s/-dev/-dev${COMMIT_NUM}/" cmake/VersionSource.cmake
- name: Install
run: python -m pip install . -v
- name: Test
run: python -m pytest --cov exactextract --cov-report lcov python/tests
- name: Upload coverage report
uses: codecov/codecov-action@v4
with:
files: coverage.lcov
token: ${{ secrets.CODECOV_TOKEN }}
- name: Build source distribution
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
run: python -m build . --sdist
- name: Check source distribution
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
run: python -m twine check dist/*.gz
- name: Upload distribution(s)
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
uses: actions/upload-artifact@v4
with:
name: release-sdist
path: ./dist/*.tar.gz
# Largely taken from https://github.com/shapely/shapely/blob/main/.github/workflows/release.yml
build_wheels:
name: Build ${{ matrix.arch }} wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' || github.event_name == 'workflow_dispatch'
env:
GEOS_VERSION: "3.12.2"
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
arch: x86_64
- os: windows-2019
arch: x86
msvc_arch: x86
- os: windows-2019
arch: AMD64
msvc_arch: x64
- os: macos-13
arch: x86_64
cmake_osx_architectures: x86_64
- os: macos-14
arch: arm64
cmake_osx_architectures: arm64
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Cache GEOS build
uses: actions/cache@v4
with:
path: ${{ runner.temp }}/geos-${{ env.GEOS_VERSION }}
key: ${{ matrix.os }}-${{ matrix.arch }}-${{ env.GEOS_VERSION }}-${{ hashFiles('ci/*') }}
- name: Add GEOS LICENSE
run: |
cp ci/wheels/licenses/LICENSE_GEOS .
shell: bash
- name: Add MSVC LICENSE
run: |
cp ci/wheels/licenses/LICENSE_win32 .
shell: bash
if: ${{ matrix.os == 'windows-2019' }}
- name: Activate MSVC
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.msvc_arch }}
if: ${{ matrix.msvc_arch }}
- name: Set development version number
run: |
COMMIT_NUM=$(git rev-list $(git describe --tags --abbrev=0).. --count)
echo "${COMMIT_NUM} commits since last tag"
sed -i.old "s/-dev/-dev${COMMIT_NUM}/" cmake/VersionSource.cmake
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_SKIP: cp36-* cp37-* cp38-* pp* *musllinux* *-manylinux_i686
CIBW_TEST_SKIP: "cp38-macosx_arm64"
CIBW_ENVIRONMENT_LINUX:
GEOS_VERSION=${{ env.GEOS_VERSION }}
GEOS_INSTALL=/host${{ runner.temp }}/geos-${{ env.GEOS_VERSION }}
GEOS_DIR=/host${{ runner.temp }}/geos-${{ env.GEOS_VERSION }}
GEOS_CONFIG=/host${{ runner.temp }}/geos-${{ env.GEOS_VERSION }}/bin/geos-config
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/host${{ runner.temp }}/geos-${{ env.GEOS_VERSION }}/lib
CIBW_ENVIRONMENT_MACOS:
GEOS_INSTALL=${{ runner.temp }}/geos-${{ env.GEOS_VERSION }}
GEOS_DIR=${{ runner.temp }}/geos-${{ env.GEOS_VERSION }}
GEOS_CONFIG=${{ runner.temp }}/geos-${{ env.GEOS_VERSION }}/bin/geos-config
MACOSX_DEPLOYMENT_TARGET=10.9
CMAKE_OSX_ARCHITECTURES='${{ matrix.cmake_osx_architectures }}'
CIBW_ENVIRONMENT_WINDOWS:
GEOS_INSTALL='${{ runner.temp }}\geos-${{ env.GEOS_VERSION }}'
GEOS_DIR='${{ runner.temp }}\geos-${{ env.GEOS_VERSION }}'
GEOS_LIBRARY_PATH='${{ runner.temp }}\geos-${{ env.GEOS_VERSION }}\lib'
GEOS_INCLUDE_PATH='${{ runner.temp }}\geos-${{ env.GEOS_VERSION }}\include'
CIBW_BEFORE_ALL: ./ci/wheels/install_geos.sh
CIBW_BEFORE_ALL_WINDOWS: ci\wheels\install_geos.cmd
CIBW_BEFORE_BUILD_WINDOWS:
pip install delvewheel
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: delvewheel repair --add-path ${{ runner.temp }}\geos-${{ env.GEOS_VERSION }}\bin -w {dest_dir} {wheel}
CIBW_BUILD_FRONTEND: "pip; args: -vvv"
CIBW_TEST_REQUIRES: pytest numpy
CIBW_TEST_COMMAND: >
python -c "import exactextract; exactextract.__version__" &&
python -m pytest {package}/python/tests/test_exact_extract.py {package}/python/tests/test_operation.py {package}/python/tests/test_processor.py -s -v
- uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
upload_pypi:
name: Publish on PyPI
needs: [build_wheels, build]
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) || github.event.inputs.publish_to_pypi == 'true'
runs-on: ubuntu-latest
permissions:
id-token: write
environment:
name: pypi
steps:
- uses: actions/download-artifact@v4
with:
pattern: release-*
merge-multiple: true
path: dist
- name: Upload Release Assets to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
repository-url: ${{ github.event_name == 'workflow_dispatch' && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }}