Skip to content

Commit

Permalink
BLD: cleanup setup.py and pyproject.toml
Browse files Browse the repository at this point in the history
Simplify some of the setup.py build work now that we have removed
more extension libraries. Move the static content over to pyproject.toml
and migrate more content to the modern build utilities.
  • Loading branch information
greglucas committed Jun 25, 2023
1 parent 8b0b7eb commit 831bed3
Show file tree
Hide file tree
Showing 15 changed files with 212 additions and 405 deletions.
46 changes: 0 additions & 46 deletions .appveyor.yml

This file was deleted.

46 changes: 3 additions & 43 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,15 @@ apt-run: &apt-install
g++ \
make
env-run: &env-setup
# Create the basic testing environment
# Mixing conda-forge and defaults in root is a recipe for trouble, so create
# a separate environment.
name: Setup conda environment
command: |
conda config \
--set always_yes yes \
--set changeps1 no \
--set show_channel_urls yes \
--set auto_activate_base false
conda config --add channels conda-forge
conda create -n test-environment python=$PYTHON_VERSION
deps-run: &deps-install
name: Install Python dependencies
command: |
conda install -n test-environment --quiet \
cython \
'matplotlib>3.3' \
numpy \
owslib \
pillow \
pyproj \
pykdtree \
pyshp \
scipy \
setuptools_scm \
shapely \
$EXTRA_PACKAGES \
--file docs/doc-requirements.txt
conda list -n test-environment
cp-run: &cp-install
name: Install Cartopy
command: |
source activate test-environment
pip install -ve .
python -m pip install --upgrade --user pip
python -m pip install -ve .[doc]
doc-run: &doc-build
name: Build documentation
command: |
source activate test-environment
PYPROJ_GLOBAL_CONTEXT=ON
make -C docs html
Expand All @@ -72,16 +37,11 @@ doc-run: &doc-build
jobs:
docs-python3:
docker:
- image: continuumio/miniconda3:latest
- image: cimg/python:3.11
steps:
- checkout

- run: *apt-install
- run:
<<: *env-setup
environment:
PYTHON_VERSION: 3.11
- run: *deps-install
- run: *cp-install

- run: *doc-build
Expand Down
62 changes: 26 additions & 36 deletions .github/workflows/ci-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,81 +10,71 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.9, '3.10', '3.11']
shapely-dev: [false]
include:
- os: ubuntu-latest
python-version: '3.11'
shapely-dev: true
defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: test-environment
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
channels: conda-forge/label/testing,conda-forge
cache: 'pip'

- name: Minimum packages
# Only run on Linux for now
# Conda's linux packages don't grab the testing label of matplotlib causing failures due to freetype differences
if: matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest'
id: minimum-packages
run: |
echo "PACKAGES=cython=0.29.24 matplotlib-base=3.4 numpy=1.21 owslib=0.24.1 pyproj=3.1 proj=8.0 scipy=1.6.3 shapely=1.7.1" >> $GITHUB_ENV
- name: Latest packages
if: steps.minimum-packages.conclusion == 'skipped' && !matrix.shapely-dev
run: |
echo "PACKAGES=cython fiona matplotlib-base numpy pyproj pykdtree scipy shapely" >> $GITHUB_ENV
- name: Latest packages with Shapely dev
if: steps.minimum-packages.conclusion == 'skipped' && matrix.shapely-dev
run: |
echo "PACKAGES=cython fiona matplotlib-base numpy pyproj pykdtree scipy geos" >> $GITHUB_ENV
pip install cython==0.29.24 matplotlib==3.4.3 numpy==1.21 owslib==0.24.1 pyproj==3.1 scipy==1.6.3 shapely==1.7.1
- name: Coverage packages
id: coverage
# only want the coverage to be run on the latest ubuntu
if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest'
run: |
echo "PACKAGES=$PACKAGES pytest-cov coveralls" >> $GITHUB_ENV
echo "CYTHON_COVERAGE=1" >> $GITHUB_ENV
echo "EXTRA_TEST_ARGS=--cov=cartopy -ra" >> $GITHUB_ENV
- name: Install dependencies
run: |
PACKAGES="$PACKAGES owslib pep8 pillow pyshp pytest pytest-mpl!=0.16.0"
PACKAGES="$PACKAGES pytest-xdist setuptools_scm"
conda install $PACKAGES
conda info -a
conda list
# Also add doctest here to avoid windows runners which expect a different path separator
echo "EXTRA_TEST_ARGS=--cov=cartopy -ra --doctest-modules" >> $GITHUB_ENV
pip install cython
- name: Install Shapely dev
if: matrix.shapely-dev
run: |
python -m pip install git+https://github.com/shapely/shapely.git@main
# Install Shapely from source on ubuntu
sudo apt-get update
sudo apt-get install -yy libgeos-dev
pip install git+https://github.com/shapely/shapely.git@main
- name: Install Cartopy
id: install
run: |
MPL_CONFIG_DIR=~/.config/matplotlib
mkdir -p $MPL_CONFIG_DIR
echo "backend : agg" > $MPL_CONFIG_DIR/matplotlibrc
pip install --no-deps -e .
pip install -e .[test]
python -c "import cartopy; print('Version ', cartopy.__version__)"
- name: Install extras
# Default is to install just the minimum testing requirements,
# but we want to get as much coverage as possible.
if: steps.minimum-packages.conclusion == 'skipped'
run: |
pip install .[extras,ows,plotting]
- name: Testing
id: test
# we need to force bash to use line continuations
shell: bash
run: |
# Check that the downloader tool at least knows where to get the data from (but don't actually download it)
python tools/cartopy_feature_download.py gshhs physical --dry-run
CARTOPY_GIT_DIR=$PWD
PYPROJ_GLOBAL_CONTEXT=ON pytest -ra -n 4 --doctest-modules \
pytest -ra -n 4 \
--color=yes \
--mpl --mpl-generate-summary=html \
--mpl-results-path="cartopy_test_output-${{ matrix.os }}-${{ matrix.python-version }}" \
Expand Down
135 changes: 90 additions & 45 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,108 @@
name: Build and upload to PyPI

concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }}
cancel-in-progress: true

# Only build on published releases
on:
release:
types:
- published
on: [push, pull_request]
# on:
# release:
# types:
# - published

jobs:
build:
name: Build sdist
runs-on: ubuntu-18.04
generate-wheels-matrix:
name: Generate wheels matrix
runs-on: ubuntu-latest
outputs:
include: ${{ steps.set-matrix.outputs.include }}
steps:
- uses: actions/checkout@v3
- name: Install cibuildwheel
run: pipx install cibuildwheel==2.12.0
- id: set-matrix
run: |
MATRIX=$(
{
cibuildwheel --print-build-identifiers --platform linux \
| jq -nRc '{"only": inputs, "os": "ubuntu-latest"}' \
&& cibuildwheel --print-build-identifiers --platform macos \
| jq -nRc '{"only": inputs, "os": "macos-latest"}' \
&& cibuildwheel --print-build-identifiers --platform windows \
| jq -nRc '{"only": inputs, "os": "windows-2019"}'
} | jq -sc
)
echo "include=$MATRIX" >> $GITHUB_OUTPUT
env:
CIBW_BUILD: "cp39-* cp310-* cp311-*"
# Skip 32 bit windows builds due to compiler
# Skip musllinux because there aren't musllinux wheels yet
CIBW_SKIP: "*-win32 *-musllinux*"
CIBW_ARCHS_MACOS: x86_64 arm64
build_wheels:
name: Build ${{ matrix.os }} ${{ matrix.only }}
needs: generate-wheels-matrix
strategy:
matrix:
include: ${{ fromJson(needs.generate-wheels-matrix.outputs.include) }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}

shell: bash
steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: test-environment
python-version: ${{ matrix.python-version }}
channels: conda-forge/label/testing,conda-forge

- name: Install dependencies
run: |
PACKAGES="cython fiona matplotlib-base numpy pyproj pykdtree scipy"
PACKAGES="$PACKAGES owslib pep8 pillow pyshp pytest"
PACKAGES="$PACKAGES pytest-xdist setuptools_scm shapely"
conda install $PACKAGES
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Create sdist
run: python setup.py build_ext sdist
- uses: pypa/[email protected]
with:
only: ${{ matrix.only }}

- name: Save built packages as artifact
uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v3
with:
name: packages-${{ runner.os }}-${{ matrix.python-version }}
path: dist/
if-no-files-found: error
retention-days: 5

publish:
name: Publish to PyPI
needs: build
environment:
name: PyPI
url: https://pypi.org/project/cartopy
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
runs-on: ubuntu-18.04
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- name: Download packages
uses: actions/download-artifact@v3
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.11'

- name: Consolidate packages for upload
- name: Build sdist
run: |
mkdir dist
cp packages-*/* dist/
python -m pip install build
python -m build --sdist
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz

# publish:
# name: Publish to PyPI
# needs: [build_wheels, build_sdist]
# environment:
# name: PyPI
# url: https://pypi.org/project/cartopy
# permissions:
# id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
# runs-on: ubuntu-18.04

# steps:
# - name: Download packages
# uses: actions/download-artifact@v3

# - name: Consolidate packages for upload
# run: |
# mkdir dist
# cp packages-*/* dist/

- name: Publish Package
uses: pypa/[email protected]
# - name: Publish Package
# uses: pypa/[email protected]
Loading

0 comments on commit 831bed3

Please sign in to comment.