tobiko/tools/ci/activate
Federico Ressi e91356faeb Fix tools/ci/tox script when 'python' command is not available
Change-Id: I73f5b45de60f47a489a8140ab63baa899599e34e
2020-01-27 11:38:01 +01:00

35 lines
951 B
Plaintext

function get_ci_tools_dir {
local tools_dir=$(dirname "${BASH_SOURCE[0]}")
realpath "${tools_dir}"
}
function realpath {
${REALPATH} "$@"
}
function get_realpath {
(
export PATH=${CI_TOOLS_ORIGINAL_PATH:-${PATH}}
local tools_dir=$(dirname "${BASH_SOURCE[0]}")
local python=$(which python3 || which python2 || wich python)
if [ -x "${python}" ] && "${python}" --version > /dev/null; then
local script="${tools_dir}/realpath.py"
local script=$("${python}" "${script}" "${script}")
echo "${python}" "${script}"
else
echo "Python command not found!" 1>&2
exit 1
fi
)
}
export REALPATH=${REALPATH:-$(get_realpath)}
export CI_TOOLS_DIR=${CI_TOOLS_DIR:-$(get_ci_tools_dir)}
export CI_TOOLS_ORIGINAL_PATH=${CI_TOOLS_ORIGINAL_PATH:-${PATH}}
export PATH=${CI_TOOLS_DIR}:${PATH}
export PYTHONWARNINGS=${PYTHONWARNINGS:-ignore}