From 7e8fd4c95eaad2b6dc5b0dc7f0df5d4d912dbec1 Mon Sep 17 00:00:00 2001 From: Brady Planden Date: Tue, 20 Feb 2024 14:04:26 +0000 Subject: [PATCH] Updt. matrix generation for incompatible pybamm/python versions --- README.md | 2 +- scripts/ci/build_matrix.sh | 28 ++++++++++++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) mode change 100644 => 100755 scripts/ci/build_matrix.sh diff --git a/README.md b/README.md index 3a3e4881b..b3c9cd324 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ pip install -e "path/to/pybop" To check whether PyBOP has been installed correctly, run one of the examples in the following section. For a development installation, please refer to the [contributing guide](https://github.com/pybop-team/PyBOP/blob/develop/CONTRIBUTING.md#Installation). ### Prerequisites -To use and/or contribute to PyBOP, first install Python (3.8-3.11). On a Debian-based distribution, this looks like: +To use and/or contribute to PyBOP, first install Python (3.8 — 3.12). On a Debian-based distribution, this looks like: ```bash sudo apt update diff --git a/scripts/ci/build_matrix.sh b/scripts/ci/build_matrix.sh old mode 100644 new mode 100755 index 6ef0f6c1f..3ddbae00a --- a/scripts/ci/build_matrix.sh +++ b/scripts/ci/build_matrix.sh @@ -12,22 +12,38 @@ python_version=("3.8" "3.9" "3.10" "3.11" "3.12") os=("ubuntu-latest" "windows-latest" "macos-latest") # This command fetches the last three PyBaMM versions excluding release candidates from PyPI -pybamm_version=($(curl -s https://pypi.org/pypi/pybamm/json | jq -r '.releases | keys[]' | grep -v rc | tail -n 3 | awk '{print "\"" $1 "\"" }' | paste -sd " " -)) +pybamm_version=($(curl -s https://pypi.org/pypi/pybamm/json | jq -r '.releases | keys[]' | grep -v rc | tail -n 3 | paste -sd " " -)) # open dict json='{ "include": [ ' +# Function to check if a PyBaMM version is compatible with a Python version +is_compatible() { + local pybamm_ver="$1" + local py_ver="$2" + + # Compatibility check + if [[ "$pybamm_ver" == "23.5" && "$py_ver" == "3.12" ]]; then + return 1 # Incompatible + elif [[ "$pybamm_ver" == "23.9" && "$py_ver" == "3.12" ]]; then + return 1 # Incompatible + fi + + return 0 # Compatible +} # loop through each combination of variables to generate matrix components for py_ver in "${python_version[@]}"; do for os_type in "${os[@]}"; do for pybamm_ver in "${pybamm_version[@]}"; do - json+='{ - "os": "'$os_type'", - "python_version": "'$py_ver'", - "pybamm_version": '$pybamm_ver' - },' + if is_compatible "$pybamm_ver" "$py_ver"; then + json+='{ + "os": "'$os_type'", + "python_version": "'$py_ver'", + "pybamm_version": "'$pybamm_ver'" + },' + fi done done done