forked from mkdocstrings/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultirun.sh
More file actions
executable file
·26 lines (23 loc) · 814 Bytes
/
multirun.sh
File metadata and controls
executable file
·26 lines (23 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env bash
set -e
PYTHON_VERSIONS="${PYTHON_VERSIONS-3.7 3.8 3.9 3.10 3.11}"
restore_previous_python_version() {
if pdm use -f "$1" &>/dev/null; then
echo "> Restored previous Python version: ${1##*/}"
fi
}
if [ -n "${PYTHON_VERSIONS}" ]; then
old_python_version="$(pdm config python.path)"
echo "> Currently selected Python version: ${old_python_version##*/}"
trap "restore_previous_python_version ${old_python_version}" EXIT
for python_version in ${PYTHON_VERSIONS}; do
if pdm use -f "python${python_version}" &>/dev/null; then
echo "> pdm run $@ (python${python_version})"
pdm run "$@"
else
echo "> pdm use -f python${python_version}: Python interpreter not available?" >&2
fi
done
else
pdm run "$@"
fi