Skip to content

Commit

Permalink
Refactor wheel testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dalcinl committed Oct 15, 2023
1 parent 9e0667f commit 724518b
Show file tree
Hide file tree
Showing 7 changed files with 454 additions and 119 deletions.
16 changes: 16 additions & 0 deletions .cibw/test-Linux-debian.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -euo pipefail

packages=(
python3.11-venv
pypy3
libmpich12
libopenmpi3
)
sudo=$(command -v sudo || true)
$sudo apt update -y
$sudo apt install -y ${packages[@]}
$sudo ln -sr /usr/lib/$(arch)-linux-gnu/libmpi{ch,}.so.12

sdir=$(cd "$(dirname -- "$0")" && pwd -P)
$sdir/test-basic.sh
25 changes: 25 additions & 0 deletions .cibw/test-Linux-fedora.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -euo pipefail

packages=(
python3.6
python3.7
python3.8
python3.9
python3.10
python3.11
python3.12
pypy3.9
pypy3.10
mpich
openmpi
)
sudo=$(command -v sudo || true)
opts=--setopt=install_weak_deps=False
$sudo dnf install -y $opts ${packages[@]}
set +u
source /etc/profile.d/modules.sh
set -u

sdir=$(cd "$(dirname -- "$0")" && pwd -P)
$sdir/test-basic.sh
17 changes: 17 additions & 0 deletions .cibw/test-Linux-ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -euo pipefail

packages=(
python3.10-venv
python3.11-venv
pypy3
libmpich12
libopenmpi3
)
sudo=$(command -v sudo || true)
$sudo apt update -y
$sudo apt install -y ${packages[@]}
$sudo ln -sr /usr/lib/$(arch)-linux-gnu/libmpi{ch,}.so.12

sdir=$(cd "$(dirname -- "$0")" && pwd -P)
$sdir/test-basic.sh
5 changes: 5 additions & 0 deletions .cibw/test-Windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
set -euo pipefail

sdir=$(cd "$(dirname -- "$0")" && pwd -P)
$sdir/test-basic.sh
104 changes: 104 additions & 0 deletions .cibw/test-basic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/bin/bash
set -euo pipefail

wheelhouse="${1:-dist}"

PYTHON=(
"${python36-python3.6}"
"${python37-python3.7}"
"${python38-python3.8}"
"${python39-python3.9}"
"${python310-python3.10}"
"${python311-python3.11}"
"${python312-python3.12}"
"${pypy37-pypy3.7}"
"${pypy38-pypy3.8}"
"${pypy39-pypy3.9}"
"${pypy310-pypy3.10}"
)

if [[ $(uname) =~ NT ]]; then
MPI=(impi msmpi)
bin="Scripts"
exe=".exe"
else
MPI=(mpich openmpi)
bin="bin"
exe=""
fi

venvroot=$(mktemp -d)
trap "rm -rf $venvroot" EXIT
export PIP_QUIET=1

function setup-python {
test -z $(command -v "$python") && return 1
venvdir=$(mktemp -d -p "$venvroot" XXX)
"$python" -m venv "$venvdir"
python="$venvdir/$bin/python$exe"
"$python" --version
"$python" -m pip install pip --upgrade
}

function setup-mpi4py {
"$python" -m pip install mpi4py --no-index --find-links="$wheelhouse"
test $? -ne 0 && return 1
"$python" -m mpi4py --version
}

function setup-mpi {
local mpi=$1
if command -v brew > /dev/null; then
brew unlink mpich openmpi > /dev/null
brew link $mpi > /dev/null
elif command -v module > /dev/null; then
module unload mpi
module load mpi/$mpi-$(arch)
else
export MPI4PY_MPIABI=$mpi
fi
}

function teardown-mpi {
local mpi=$1
if command -v brew > /dev/null; then
brew unlink $mpi > /dev/null
elif command -v module > /dev/null; then
module unload mpi/$mpi-$(arch)
fi
unset MPI4PY_MPIABI
unset MPI4PY_LIBMPI
}

function mpi4py-test-basic {
"$python" -m mpi4py --mpi-std-version
"$python" -m mpi4py --mpi-lib-version | head -n 1
}

for python in ${PYTHON[@]}; do
test -z $(command -v "$python") && continue
pyversion=$("$python" -c "import sys; print(sys.version.split()[0])")
pyimpname=$("$python" -c "import sys; print(sys.implementation.name)")
echo "::group::Python $pyversion [$pyimpname]"
setup-python || continue
setup-mpi4py || continue
for mpi in ${MPI[@]}; do
echo "* Use MPI=$mpi"
setup-mpi $mpi
echo "- Test MPIABI discovery"
mpi4py-test-basic
if [ $mpi == $mpi ]; then
export MPI4PY_MPIABI=$mpi
echo "- Test MPIABI=$MPI4PY_MPIABI"
mpi4py-test-basic
fi
if [ $mpi == mpich -o $mpi == openmpi ]; then
export MPI4PY_MPIABI=mpi31-$mpi
echo "- Test MPIABI=$MPI4PY_MPIABI"
mpi4py-test-basic
fi
teardown-mpi $mpi
echo ""
done
echo "::endgroup::"
done
27 changes: 27 additions & 0 deletions .cibw/test-macOS.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
set -euo pipefail

packages_py=(
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
pypy3.9
pypy3.10
)
packages_mpi=(
mpich
openmpi
)
brew install ${packages_py[@]}
for mpi in ${packages_mpi[@]}; do
brew unlink $mpi || true
done
for mpi in ${packages_mpi[@]}; do
brew install $mpi
brew unlink $mpi
done

sdir=$(cd "$(dirname -- "$0")" && pwd -P)
$sdir/test-basic.sh
Loading

0 comments on commit 724518b

Please sign in to comment.