[Scripts] Warning instead of error in setupvars scripts (#13554)
* Warning instead of error in setupvars script * apply comments
This commit is contained in:
parent
1cc4c17daf
commit
57e6dd1b7e
@ -66,11 +66,17 @@ set MIN_REQUIRED_PYTHON_VERSION_MINOR=6
|
|||||||
set MAX_SUPPORTED_PYTHON_VERSION_MINOR=9
|
set MAX_SUPPORTED_PYTHON_VERSION_MINOR=9
|
||||||
|
|
||||||
python --version 2>NUL
|
python --version 2>NUL
|
||||||
if errorlevel 1 (
|
if errorlevel 1 (call :python_not_installed) else (call :check_python_version)
|
||||||
echo Error^: Python is not installed. Please install one of Python %PYTHON_VERSION_MAJOR%.%MIN_REQUIRED_PYTHON_VERSION_MINOR% - %PYTHON_VERSION_MAJOR%.%MAX_SUPPORTED_PYTHON_VERSION_MINOR% ^(64-bit^) from https://www.python.org/downloads/
|
|
||||||
exit /B 1
|
|
||||||
)
|
|
||||||
|
|
||||||
|
echo [setupvars.bat] OpenVINO environment initialized
|
||||||
|
|
||||||
|
exit /B 0
|
||||||
|
|
||||||
|
:python_not_installed
|
||||||
|
echo Warning^: Python is not installed. Please install one of Python %PYTHON_VERSION_MAJOR%.%MIN_REQUIRED_PYTHON_VERSION_MINOR% - %PYTHON_VERSION_MAJOR%.%MAX_SUPPORTED_PYTHON_VERSION_MINOR% ^(64-bit^) from https://www.python.org/downloads/
|
||||||
|
exit /B 0
|
||||||
|
|
||||||
|
:check_python_version
|
||||||
:: Check Python version if user did not pass -pyver
|
:: Check Python version if user did not pass -pyver
|
||||||
if "%python_version%" == "" (
|
if "%python_version%" == "" (
|
||||||
for /F "tokens=* USEBACKQ" %%F IN (`python -c "import sys; print(str(sys.version_info[0])+'.'+str(sys.version_info[1]))" 2^>^&1`) DO (
|
for /F "tokens=* USEBACKQ" %%F IN (`python -c "import sys; print(str(sys.version_info[0])+'.'+str(sys.version_info[1]))" 2^>^&1`) DO (
|
||||||
@ -93,14 +99,14 @@ if "%pyversion_major%" equ "%PYTHON_VERSION_MAJOR%" (
|
|||||||
|
|
||||||
if not "%check_pyversion%"=="true" (
|
if not "%check_pyversion%"=="true" (
|
||||||
echo Unsupported Python version. Please install one of Python %PYTHON_VERSION_MAJOR%.%MIN_REQUIRED_PYTHON_VERSION_MINOR% - %PYTHON_VERSION_MAJOR%.%MAX_SUPPORTED_PYTHON_VERSION_MINOR% ^(64-bit^) from https://www.python.org/downloads/
|
echo Unsupported Python version. Please install one of Python %PYTHON_VERSION_MAJOR%.%MIN_REQUIRED_PYTHON_VERSION_MINOR% - %PYTHON_VERSION_MAJOR%.%MAX_SUPPORTED_PYTHON_VERSION_MINOR% ^(64-bit^) from https://www.python.org/downloads/
|
||||||
exit /B 1
|
exit /B 0
|
||||||
)
|
)
|
||||||
|
|
||||||
:: Check Python bitness
|
:: Check Python bitness
|
||||||
python -c "import sys; print(64 if sys.maxsize > 2**32 else 32)" 2 > NUL
|
python -c "import sys; print(64 if sys.maxsize > 2**32 else 32)" 2 > NUL
|
||||||
if errorlevel 1 (
|
if errorlevel 1 (
|
||||||
echo Error^: Error during installed Python bitness detection
|
echo Warning^: Cannot determine installed Python bitness
|
||||||
exit /B 1
|
exit /B 0
|
||||||
)
|
)
|
||||||
|
|
||||||
for /F "tokens=* USEBACKQ" %%F IN (`python -c "import sys; print(64 if sys.maxsize > 2**32 else 32)" 2^>^&1`) DO (
|
for /F "tokens=* USEBACKQ" %%F IN (`python -c "import sys; print(64 if sys.maxsize > 2**32 else 32)" 2^>^&1`) DO (
|
||||||
@ -109,13 +115,10 @@ for /F "tokens=* USEBACKQ" %%F IN (`python -c "import sys; print(64 if sys.maxsi
|
|||||||
|
|
||||||
if not "%bitness%"=="64" (
|
if not "%bitness%"=="64" (
|
||||||
echo Unsupported Python bitness. Please install one of Python %PYTHON_VERSION_MAJOR%.%MIN_REQUIRED_PYTHON_VERSION_MINOR% - %PYTHON_VERSION_MAJOR%.%MAX_SUPPORTED_PYTHON_VERSION_MINOR%^(64-bit^) from https://www.python.org/downloads/
|
echo Unsupported Python bitness. Please install one of Python %PYTHON_VERSION_MAJOR%.%MIN_REQUIRED_PYTHON_VERSION_MINOR% - %PYTHON_VERSION_MAJOR%.%MAX_SUPPORTED_PYTHON_VERSION_MINOR%^(64-bit^) from https://www.python.org/downloads/
|
||||||
exit /B 1
|
exit /B 0
|
||||||
)
|
)
|
||||||
|
|
||||||
set PYTHONPATH=%INTEL_OPENVINO_DIR%\python\python%pyversion_major%.%pyversion_minor%;%INTEL_OPENVINO_DIR%\python\python3;%PYTHONPATH%
|
set PYTHONPATH=%INTEL_OPENVINO_DIR%\python\python%pyversion_major%.%pyversion_minor%;%INTEL_OPENVINO_DIR%\python\python3;%PYTHONPATH%
|
||||||
|
|
||||||
echo [setupvars.bat] OpenVINO environment initialized
|
|
||||||
|
|
||||||
exit /B 0
|
exit /B 0
|
||||||
|
|
||||||
:GetFullPath
|
:GetFullPath
|
||||||
|
@ -93,65 +93,80 @@ if [ -f "$INSTALLDIR/extras/opencv/setupvars.sh" ]; then
|
|||||||
source "$INSTALLDIR/extras/opencv/setupvars.sh"
|
source "$INSTALLDIR/extras/opencv/setupvars.sh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$python_version" ]; then
|
OS_NAME=""
|
||||||
python_version=$(python3 -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')
|
if command -v lsb_release >/dev/null 2>&1; then
|
||||||
fi
|
OS_NAME=$(lsb_release -i -s)
|
||||||
|
|
||||||
# splitting Python version variable depending on the used shell
|
|
||||||
if [ -n "$ZSH_VERSION" ]; then
|
|
||||||
version_arr=(${(@s:.:)python_version})
|
|
||||||
if [ "${#version_arr[@]}" -ge "2" ]; then
|
|
||||||
# zsh starts indexing from 1
|
|
||||||
python_version_major=${version_arr[1]}
|
|
||||||
python_version_minor=${version_arr[2]}
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
version_arr=(${python_version//./ })
|
|
||||||
if [ "${#version_arr[@]}" -ge "2" ]; then
|
|
||||||
python_version_major=${version_arr[0]}
|
|
||||||
python_version_minor=${version_arr[1]}
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PYTHON_VERSION_MAJOR="3"
|
PYTHON_VERSION_MAJOR="3"
|
||||||
MIN_REQUIRED_PYTHON_VERSION_MINOR="6"
|
MIN_REQUIRED_PYTHON_VERSION_MINOR="6"
|
||||||
MAX_SUPPORTED_PYTHON_VERSION_MINOR="9"
|
MAX_SUPPORTED_PYTHON_VERSION_MINOR="9"
|
||||||
|
|
||||||
if [ "$PYTHON_VERSION_MAJOR" != "$python_version_major" ] ||
|
check_python_version () {
|
||||||
[ "$python_version_minor" -lt "$MIN_REQUIRED_PYTHON_VERSION_MINOR" ] ||
|
if [ -z "$python_version" ]; then
|
||||||
[ "$python_version_minor" -gt "$MAX_SUPPORTED_PYTHON_VERSION_MINOR" ] ; then
|
python_version=$(python3 -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')
|
||||||
echo "[setupvars.sh] ERROR: Unsupported Python version. Please install one of Python" \
|
fi
|
||||||
"${PYTHON_VERSION_MAJOR}.${MIN_REQUIRED_PYTHON_VERSION_MINOR} -" \
|
|
||||||
"${PYTHON_VERSION_MAJOR}.${MAX_SUPPORTED_PYTHON_VERSION_MINOR} (64-bit) from https://www.python.org/downloads/"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
OS_NAME=""
|
# splitting Python version variable depending on the used shell
|
||||||
if command -v lsb_release >/dev/null 2>&1; then
|
if [ -n "$ZSH_VERSION" ]; then
|
||||||
OS_NAME=$(lsb_release -i -s)
|
version_arr=(${(@s:.:)python_version})
|
||||||
fi
|
if [ "${#version_arr[@]}" -ge "2" ]; then
|
||||||
|
# zsh starts indexing from 1
|
||||||
python_bitness=$(python"$python_version" -c 'import sys; print(64 if sys.maxsize > 2**32 else 32)')
|
python_version_major=${version_arr[1]}
|
||||||
if [ "$python_bitness" != "" ] && [ "$python_bitness" != "64" ] && [ "$OS_NAME" != "Raspbian" ]; then
|
python_version_minor=${version_arr[2]}
|
||||||
echo "[setupvars.sh] WARNING: 64 bitness for Python $python_version is required"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$python_version" ]; then
|
|
||||||
if [[ -d $INTEL_OPENVINO_DIR/python ]]; then
|
|
||||||
# add path to OpenCV API for Python 3.x
|
|
||||||
export PYTHONPATH="$INTEL_OPENVINO_DIR/python/python3:$PYTHONPATH"
|
|
||||||
pydir=$INTEL_OPENVINO_DIR/python/python$python_version
|
|
||||||
if [[ -d $pydir ]]; then
|
|
||||||
# add path to Inference Engine Python API
|
|
||||||
export PYTHONPATH="${pydir}:${PYTHONPATH}"
|
|
||||||
else
|
|
||||||
echo "[setupvars.sh] WARNING: Can not find OpenVINO Python module for python${python_version} by path ${pydir}"
|
|
||||||
echo "[setupvars.sh] WARNING: OpenVINO Python environment does not set properly"
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "[setupvars.sh] WARNING: Can not find OpenVINO Python binaries by path ${INTEL_OPENVINO_DIR}/python"
|
version_arr=(${python_version//./ })
|
||||||
echo "[setupvars.sh] WARNING: OpenVINO Python environment does not set properly"
|
if [ "${#version_arr[@]}" -ge "2" ]; then
|
||||||
|
python_version_major=${version_arr[0]}
|
||||||
|
python_version_minor=${version_arr[1]}
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$PYTHON_VERSION_MAJOR" != "$python_version_major" ] ||
|
||||||
|
[ "$python_version_minor" -lt "$MIN_REQUIRED_PYTHON_VERSION_MINOR" ] ||
|
||||||
|
[ "$python_version_minor" -gt "$MAX_SUPPORTED_PYTHON_VERSION_MINOR" ] ; then
|
||||||
|
echo "[setupvars.sh] WARNING: Unsupported Python version. Please install one of Python" \
|
||||||
|
"${PYTHON_VERSION_MAJOR}.${MIN_REQUIRED_PYTHON_VERSION_MINOR} -" \
|
||||||
|
"${PYTHON_VERSION_MAJOR}.${MAX_SUPPORTED_PYTHON_VERSION_MINOR} (64-bit) from https://www.python.org/downloads/"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
python_bitness=$(python"$python_version" -c 'import sys; print(64 if sys.maxsize > 2**32 else 32)')
|
||||||
|
|
||||||
|
if [ "$python_bitness" != "" ] && [ "$python_bitness" != "64" ] && [ "$OS_NAME" != "Raspbian" ]; then
|
||||||
|
echo "[setupvars.sh] WARNING: 64 bitness for Python $python_version is required"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$python_version" ]; then
|
||||||
|
if [[ -d $INTEL_OPENVINO_DIR/python ]]; then
|
||||||
|
# add path to OpenCV API for Python 3.x
|
||||||
|
export PYTHONPATH="$INTEL_OPENVINO_DIR/python/python3:$PYTHONPATH"
|
||||||
|
pydir=$INTEL_OPENVINO_DIR/python/python$python_version
|
||||||
|
if [[ -d $pydir ]]; then
|
||||||
|
# add path to Inference Engine Python API
|
||||||
|
export PYTHONPATH="${pydir}:${PYTHONPATH}"
|
||||||
|
else
|
||||||
|
echo "[setupvars.sh] WARNING: Can not find OpenVINO Python module for python${python_version} by path ${pydir}"
|
||||||
|
echo "[setupvars.sh] WARNING: OpenVINO Python environment does not set properly"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "[setupvars.sh] WARNING: Can not find OpenVINO Python binaries by path ${INTEL_OPENVINO_DIR}/python"
|
||||||
|
echo "[setupvars.sh] WARNING: OpenVINO Python environment does not set properly"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
python_version_to_check="$python_version"
|
||||||
|
if [ -z "$python_version" ]; then
|
||||||
|
python_version_to_check="3"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v python"$python_version_to_check" > /dev/null 2>&1; then
|
||||||
|
echo "[setupvars.sh] WARNING: Python is not installed. Please install one of Python" \
|
||||||
|
"${PYTHON_VERSION_MAJOR}.${MIN_REQUIRED_PYTHON_VERSION_MINOR} -" \
|
||||||
|
"${PYTHON_VERSION_MAJOR}.${MAX_SUPPORTED_PYTHON_VERSION_MINOR} (64-bit) from https://www.python.org/downloads/"
|
||||||
|
else
|
||||||
|
check_python_version
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[setupvars.sh] OpenVINO environment initialized"
|
echo "[setupvars.sh] OpenVINO environment initialized"
|
||||||
|
Loading…
Reference in New Issue
Block a user