Skip to content

Commit

Permalink
test: Poetry on macOS
Browse files Browse the repository at this point in the history
Use short options for `tr` and `cut`, for compatibility with the macOS
tools.

Installing GDAL with Conda is one of the few cross-platform installation
methods available:

- GDAL 3.4.1 is not available for installation with brew
  <https://formulae.brew.sh/formula/gdal>.
- Poetry ignores declaration of different versions for macOS and Linux
  <python-poetry/poetry#5506>.

Unfortunately Conda does not yet support Python 3.11
<conda/conda#11170>, so I've dropped that.
  • Loading branch information
l0b0 committed Jan 18, 2023
1 parent 7608035 commit 344a796
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
38 changes: 25 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,53 +57,65 @@ jobs:
working-directory: flooding/sentinel2_water_extraction

test-poetry:
name: Test using Poetry on Python ${{ matrix.python }}
runs-on: ubuntu-22.04
name:
Test on ${{ matrix.runner }}, using Poetry with Python ${{ matrix.python
}}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
runner:
- macos-12
- ubuntu-22.04
python:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
include:
- runner: macos-12
pip-cache-dir: ~/Library/Caches/pip
- runner: ubuntu-22.04
pip-cache-dir: ~/.cache/pip
steps:
- name: Check out repository
uses: actions/checkout@v3.3.0

- name: Use Python ${{ matrix.python }}
id: setup-python
uses: actions/setup-python@v4.5.0
with:
python-version: ${{ matrix.python }}

- name: Cache pip
uses: actions/cache@v3.2.3
with:
path: ~/.cache/pip
path: ${{ matrix.pip-cache-dir }}
key:
${{ runner.os }}-pip-${{ secrets.CACHE_SEED }}-${{ matrix.python
}}-${{
hashFiles('./flooding/sentinel2_water_extraction/poetry.lock') }}
restore-keys:
${{ runner.os }}-pip-${{ secrets.CACHE_SEED }}-${{ matrix.python }}-

- name: Update package registry
run: sudo apt-get update

- name: Install Poetry
run: pip install --disable-pip-version-check --progress-bar=off poetry

- name: Get GDAL Python package version
run:
echo "GDAL_VERSION=$(poetry show gdal | tr --delete ' ' | grep
'^version:' | cut --delimiter=':' --fields=2)" >> $GITHUB_ENV
echo "GDAL_VERSION=$(poetry show gdal | tr -d ' ' | grep '^version:' |
cut -d ':' -f 2)" >> $GITHUB_ENV
working-directory: flooding/sentinel2_water_extraction

- name: Install GDAL
- name: Setup Conda
uses: s-weigand/setup-conda@v1.1.1
with:
conda-channels: conda-forge
python-version: ${{ steps.setup-python.outputs.python-version }}

- name: Install Conda environment packages
run:
sudo apt-get --assume-yes install "libgdal-dev=${{ env.GDAL_VERSION
}}*"
working-directory: flooding/sentinel2_water_extraction
conda install --channel=conda-forge --quiet --yes gdal=${{
env.GDAL_VERSION }} poetry

- name: Install Python packages
run: poetry install --only=main --no-root
Expand Down
3 changes: 2 additions & 1 deletion flooding/sentinel2_water_extraction/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Below are the instructions to get the Notebook up and running

## Prerequisites

- Python 3.8, 3.9, 3.10, or 3.11
- Linux (tested on Ubuntu 22.04) or macOS (tested on version 12, Monterey)
- Python 3.8, 3.9, or 3.10
- GDAL 3.4

## Get the Jupyter Notebook
Expand Down

0 comments on commit 344a796

Please sign in to comment.