aboutsummaryrefslogtreecommitdiff
blob: 325089566555e3c8f3812030da616c8443cd861e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
readonly SCRIPT=$(readlink -f "${BASH_SOURCE[0]?}")
readonly SCRIPT_NAME="${BASH_SOURCE[0]##*/}"
readonly SCRIPT_DIR="${SCRIPT%/*}"

readonly PRJROOT="${SCRIPT_DIR%/*}"
readonly PYSCRIPT="${SCRIPT_DIR}/py/${SCRIPT_NAME%.*}.py"

export PYTHONPATH="${PRJROOT}${PYTHONPATH:+:}${PYTHONPATH}"


cd "${PRJROOT}" || exit

if [[ -x "${PYSCRIPT}" ]]; then
   ${PYSCRIPT} "$@"
elif [[ -f "${PYSCRIPT}" ]]; then
   ${PYTHON:-python} ${PYSCRIPT} "$@"
else
   echo "script not found: ${PYSCRIPT}" 1>&2
   exit 9
fi