Skip to content

Commit

Permalink
Merge pull request #214 from pik-copan/201-windows_macos
Browse files Browse the repository at this point in the history
CI: add build jobs for macOS and Windows in `travis.yml`
  • Loading branch information
fkuehlein authored Feb 1, 2024
2 parents 22b19ad + 138a445 commit 296045d
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 75 deletions.
159 changes: 99 additions & 60 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,74 +1,113 @@
# This file is part of pyunicorn.
# Copyright (C) 2008--2024 Jonathan F. Donges and pyunicorn authors
# URL: <http://www.pik-potsdam.de/members/donges/software>
# License: BSD (3-clause)


# documentation & validation ==================================================

# - https://docs.travis-ci.com/user/reference/overview
# - https://docs.travis-ci.com/user/build-matrix/
# - https://docs.travis-ci.com/user/multi-os/

# - https://docs.travis-ci.com/user/build-config-validation/
# - https://config.travis-ci.com/explore


# meta ========================================================================

# enable build config validation
version: ~> 1.0

# require the branch name to be master
# save Travis budget
if: branch = master

language: python
python:
# https://docs.travis-ci.com/user/languages/python/#python-versions
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12-dev"
matrix:
fast_finish: true
# report outcomes
notifications:
email:
on_success: change
on_failure: always


# default jobs: Linux, all Python versions ====================================

arch: arm64
virt: lxd
os: linux
dist: focal
sudo: false

before_install:
# Python package manager
- travis_retry wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh -O miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"; hash -r
- conda config --set quiet yes --set always_yes yes --set changeps1 no
- travis_retry conda update -n base -c defaults conda
- travis_retry conda update --all
- conda config --set solver libmamba

# debugging info
- conda info -a
- conda list
arch: arm64
virt: lxd
language: generic
env:
jobs:
- PYTHON=3.12
- PYTHON=3.11
- PYTHON=3.10
- PYTHON=3.9
- PYTHON=3.8

before_install: export ARCH=Linux-aarch64 SED=sed

install:
# runtime dependencies
- travis_retry conda create -n test-env
- eval "$(conda shell.bash hook)"
- conda activate test-env
- travis_retry conda install -c conda-forge python=${TRAVIS_PYTHON_VERSION%-dev}
- travis_retry conda install -c conda-forge numpy scipy python-igraph h5netcdf tqdm
- travis_retry conda update -c conda-forge --all

# testing dependencies
- travis_retry conda install -c conda-forge tox flake8 pylint pytest-xdist pytest-cov codecov
- travis_retry conda install -c conda-forge networkx matplotlib cartopy sphinx

# debugging info
- conda info -a
- conda list

before_script:
# limit parallel processes to available cores (error if pattern not found)
- sed -i '/nthreads=./{s//nthreads=2/;h}; ${x;/./{x;q0};x;q1}' setup.py
- sed -i '/-j ./ {s//-j 2/; h}; ${x;/./{x;q0};x;q1}' setup.cfg
- sed -i '/-n auto/ {s//-n 2/; h}; ${x;/./{x;q0};x;q1}' pyproject.toml
- sed -i '/jobs = ./ {s//jobs = 2/; h}; ${x;/./{x;q0};x;q1}' pyproject.toml
- | # install Python via Miniconda
travis_retry wget https://repo.anaconda.com/miniconda/Miniconda3-latest-${ARCH}.sh -O miniconda.sh
bash miniconda.sh -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"; hash -r
conda config --set quiet yes --set always_yes yes --set changeps1 no
- |
travis_retry conda update -n base -c defaults conda
travis_retry conda update --all
conda config --set solver libmamba
conda info -a
conda list
travis_retry conda create -n test-env
eval "$(conda shell.bash hook)"
conda activate test-env
travis_retry conda install -c conda-forge python=${PYTHON}
- | # install dependencies
travis_retry conda install -c conda-forge numpy scipy python-igraph h5netcdf tqdm
travis_retry conda update -c conda-forge --all
travis_retry conda install -c conda-forge tox flake8 pylint pytest-xdist pytest-cov codecov
travis_retry conda install -c conda-forge networkx matplotlib cartopy sphinx
conda info -a
conda list
script:
# package
- travis_retry pip install -v -e ".[testing,docs]"
- | # limit procs to available cores (use GNU `sed`, fail if pattern not found)
${SED} -i '/nthreads=./{s//nthreads=2/;h}; ${x;/./{x;q0};x;q1}' setup.py
${SED} -i '/-j ./ {s//-j 2/; h}; ${x;/./{x;q0};x;q1}' setup.cfg
${SED} -i '/-n auto/ {s//-n 2/; h}; ${x;/./{x;q0};x;q1}' pyproject.toml
${SED} -i '/jobs = ./ {s//jobs = 2/; h}; ${x;/./{x;q0};x;q1}' pyproject.toml
# test suite
- tox -v
# install self (and dependencies, if on Windows)
- travis_retry pip install -v -e ".[tests,docs]"

after_success:
- codecov
# run test suite
- tox -v

notifications:
email:
on_success: change
on_failure: always
# report statistics
after_success: codecov


# modified jobs: OSX + Windows, newest Python version =========================
# (inherit only 1st `env.jobs` entry)

jobs:
fast_finish: true
include:
- os: osx
osx_image: xcode14
language: shell
before_install:
- export ARCH=MacOSX-x86_64 SED=gsed
- export HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1
- travis_retry brew install gnu-sed

- os: windows
language: shell
before_install:
- export ARCH=Windows-x86_64 SED=sed
- export PATH=/c/Python${PYTHON/.}:/c/Python${PYTHON/.}/Scripts:${PATH}
install:
- | # install Python via Chocolatey
travis_retry choco install python --version ${PYTHON}
travis_retry python -m pip install --upgrade pip
11 changes: 6 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ Installation
Dependencies
............
``pyunicorn`` is implemented in `Python 3 <https://docs.python.org/3/>`_ and
`Cython 3 <https://cython.org/>`_, and is tested on *Linux*, *macOS* and
*Windows*. It relies on the following open source or freely available packages,
which need to be installed on your machine. For exact dependency information,
see ``setup.cfg``.
`Cython 3 <https://cython.org/>`_, and is `tested
<https://app.travis-ci.com/github/pik-copan/pyunicorn>`_ on *Linux*, *macOS*
and *Windows*. It relies on the following open source or freely available
packages, which need to be installed on your machine. For exact dependency
information, see ``setup.cfg``.

Required at runtime:
- `numpy <http://www.numpy.org/>`_
Expand Down Expand Up @@ -154,7 +155,7 @@ please make sure that all tests pass. The test suite is managed by `tox
<http://tox.readthedocs.io/>`_ and is configured to use system-wide packages
when available. Install the test dependencies as follows::

$> pip install .[testing]
$> pip install .[tests]

The test suite can be run from anywhere in the project tree by issuing::

Expand Down
19 changes: 9 additions & 10 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ dev =
Cython >= 3.0
docs =
sphinx >= 7.0
testing =
matplotlib
tests =
tox >= 4.3
flake8 >= 6.0
pylint >= 2.17
Expand All @@ -92,44 +93,42 @@ envlist =
docs

[testenv]
extras =
testing
skip_install = true
skipsdist = true
sitepackages = true
changedir = {toxinidir}
setenv =
PYTHONPATH = {toxinidir}/src
passenv = WINDIR, LC_ALL
allowlist_externals =
flake8
pylint
pytest
sphinx-build

[testenv:style]
skipsdist = true
commands =
flake8
flake8 src/pyunicorn tests

[testenv:lint]
skipsdist = true
commands =
pylint src/pyunicorn tests

[testenv:test]
extras = tests
commands =
pytest --cov

[testenv:docs]
extras =
docs
extras = docs
commands =
sphinx-build -j 8 -W -b html -d {envtmpdir}/doctrees docs/source {envtmpdir}/html

# test tools ===================================================================

[flake8]
extend-exclude =
.git, .cache, .tox, .ropeproject, build,
docs/source/conf.py
.git, .cache, .tox, .ropeproject, build, docs/source/conf.py
extend-ignore =
E121, E123, E126, E226, E24, E704, E731, F401, F403, F405, F812, F841, W503
per-file-ignores =
Expand Down

0 comments on commit 296045d

Please sign in to comment.