2020-04-02 19:10:02 -04:00
|
|
|
#!/usr/bin/env bash
|
2018-09-25 08:43:07 -04:00
|
|
|
|
2020-11-10 22:31:17 -05:00
|
|
|
if [ -z ${PYTHON_VER+x} ]; then
|
|
|
|
# Use this version of the Python interpreter if it was not defined before.
|
2021-05-26 04:44:20 -04:00
|
|
|
# 3.6.13 is the default python3 interpreter in esp32-ci-env
|
2020-11-10 22:31:17 -05:00
|
|
|
# Jobs which doesn't support this version should define PYTHON_VER themselves
|
2022-01-31 01:20:59 -05:00
|
|
|
PYTHON_VER=3.7.10
|
2018-09-25 08:43:07 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f /opt/pyenv/activate ];
|
|
|
|
then
|
|
|
|
source /opt/pyenv/activate
|
|
|
|
pyenv global $PYTHON_VER || {
|
|
|
|
echo 'Python' $PYTHON_VER 'is not installed.'
|
|
|
|
INSTALLED_PY_VERS=$(pyenv versions --bare)
|
|
|
|
|
|
|
|
while [ ${#PYTHON_VER} -gt 0 ]
|
|
|
|
do
|
|
|
|
echo 'Tring to locate a match for' $PYTHON_VER
|
|
|
|
|
|
|
|
for ver in ${INSTALLED_PY_VERS[@]}
|
|
|
|
do
|
|
|
|
if [[ $ver == $PYTHON_VER* ]];
|
|
|
|
then
|
|
|
|
pyenv global $ver
|
|
|
|
break 2
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Removing last character and trying to find some match.
|
|
|
|
# For example, if 3.4.8 was selected but isn't installed then it will try to
|
|
|
|
# find some other installed 3.4.X version, and then some 3.X.X version.
|
|
|
|
PYTHON_VER=${PYTHON_VER: : -1}
|
|
|
|
done
|
|
|
|
}
|
|
|
|
python --version || {
|
|
|
|
echo 'No matching Python interpreter is found!'
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
elif command -v python -V 1>/dev/null 2>&1;
|
|
|
|
then
|
|
|
|
python --version
|
|
|
|
echo 'No /opt/pyenv/activate exists and Python from path is used.'
|
|
|
|
else
|
|
|
|
echo 'No /opt/pyenv/activate exists and no Python interpreter is found!'
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-11-26 22:21:33 -05:00
|
|
|
|
|
|
|
# add esp-idf local package path to PYTHONPATH so it can be imported directly
|
2022-07-12 22:34:02 -04:00
|
|
|
export PYTHONPATH="$IDF_PATH/tools:$IDF_PATH/components/partition_table:$IDF_PATH/tools/ci/python_packages:$PYTHONPATH"
|