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 5, 2023
1 parent 76c9424 commit f4f6024
Show file tree
Hide file tree
Showing 6 changed files with 411 additions and 108 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-wheel.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-wheel.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-wheel.sh
24 changes: 24 additions & 0 deletions .cibw/test-macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/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 install $mpi
brew unlink $mpi
done

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

PYTHON=(
python3.6
python3.7
python3.8
python3.9
python3.10
python3.11
python3.12
pypy3.7
pypy3.8
pypy3.9
)

wheelhouse=${1:-dist}
venvroot=$(mktemp -d)
trap "rm -rf $venvroot" EXIT
export PIP_QUIET=1

if [[ $(uname) =~ NT ]]; then
MPI=(impi msmpi)
OSTYPE=nt
else
MPI=(mpich openmpi)
OSTYPE=posix
fi

function setup-python {
local python=$1
venvdir=$venvroot/$python
$python -m venv $venvdir
if [[ $OSTYPE == posix ]]; then
source $venvdir/bin/activate
else
export PATH="$venvdir\\Scripts;$PATH"
hash -r 2> /dev/null
fi
command -v python
python -m pip install pip --upgrade
}

function setup-mpi4py {
local dist=$1
python -m pip install mpi4py --no-index --find-links=$dist
}

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 mpi4py-test-basic {
python --version
python -m mpi4py --version
python -m mpi4py --mpi-std-version
python -m mpi4py --mpi-lib-version | head -n 1
printf "\n"
}

for python in ${PYTHON[@]}; do
test -z "$(command -v $python)" && continue
setup-python $python
setup-mpi4py $wheelhouse
for mpi in ${MPI[@]}; do
setup-mpi $mpi
mpi4py-test-basic
export MPI4PY_MPIABI=$mpi
mpi4py-test-basic
if [ $mpi == mpich -o $mpi == openmpi ]; then
export MPI4PY_MPIABI=mpi31-$mpi
mpi4py-test-basic
fi
unset MPI4PY_MPIABI
done
done
Loading

0 comments on commit f4f6024

Please sign in to comment.