[Scripts] Fix setting PYTHONPATH logic (#2305)

* setupvars.sh: Added logic for exporting path env in case if it not defined

* setupvars: Removed duplicated colon

* install_openvino_dependencies: Updated copyrights

setupvars.bat: Updated notification about incorrect Python version. Removed checking ICC2019
setupvars.sh: Removed logic with choosing higher version of installed Python. Added dynamic detecting python3 major and minor version for setting path. Add checking minimum required Python version(now 3.6)
This commit is contained in:
Artyom Anokhov 2020-09-17 16:41:46 +03:00 committed by GitHub
parent 2645421df6
commit 86e39a6775
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 32 deletions

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# Copyright (c) 2018 Intel Corporation # Copyright (c) 2018 - 2020 Intel Corporation
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.

View File

@ -21,8 +21,6 @@ set SCRIPT_NAME=%~nx0
set "INTEL_OPENVINO_DIR=%ROOT%" set "INTEL_OPENVINO_DIR=%ROOT%"
set "INTEL_CVSDK_DIR=%INTEL_OPENVINO_DIR%" set "INTEL_CVSDK_DIR=%INTEL_OPENVINO_DIR%"
where /q libmmd.dll || echo Warning: libmmd.dll couldn't be found in %%PATH%%. Please check if the redistributable package for Intel(R) C++ Compiler is installed and the library path is added to the PATH environment variable. System reboot can be required to update the system environment.
:: OpenCV :: OpenCV
if exist "%INTEL_OPENVINO_DIR%\opencv\setupvars.bat" ( if exist "%INTEL_OPENVINO_DIR%\opencv\setupvars.bat" (
call "%INTEL_OPENVINO_DIR%\opencv\setupvars.bat" call "%INTEL_OPENVINO_DIR%\opencv\setupvars.bat"
@ -52,14 +50,14 @@ set "ngraph_DIR=%INTEL_OPENVINO_DIR%\deployment_tools\ngraph\cmake"
) )
:: Check if Python is installed :: Check if Python is installed
python --version 2>NUL python3 --version 2>NUL
if errorlevel 1 ( if errorlevel 1 (
echo Error^: Python is not installed. Please install Python 3.5. or 3.6 ^(64-bit^) from https://www.python.org/downloads/ echo Error^: Python is not installed. Please install Python 3.6 or higher ^(64-bit^) from https://www.python.org/downloads/
exit /B 1 exit /B 1
) )
:: Check Python version :: Check Python version
for /F "tokens=* USEBACKQ" %%F IN (`python --version 2^>^&1`) DO ( for /F "tokens=* USEBACKQ" %%F IN (`python3 --version 2^>^&1`) DO (
set version=%%F set version=%%F
) )
@ -69,18 +67,18 @@ for /F "tokens=1,2,3 delims=. " %%a in ("%version%") do (
) )
if "%Major%" geq "3" ( if "%Major%" geq "3" (
if "%Minor%" geq "5" ( if "%Minor%" geq "6" (
set python_ver=okay set python_ver=okay
) )
) )
if not "%python_ver%"=="okay" ( if not "%python_ver%"=="okay" (
echo Unsupported Python version. Please install Python 3.5 or 3.6 ^(64-bit^) from https://www.python.org/downloads/ echo Unsupported Python version. Please install Python 3.6 or higher ^(64-bit^) from https://www.python.org/downloads/
exit /B 1 exit /B 1
) )
:: Check Python bitness :: Check Python bitness
python -c "import sys; print(64 if sys.maxsize > 2**32 else 32)" 2 > NUL python3 -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 Error^: Error during installed Python bitness detection
exit /B 1 exit /B 1
@ -91,7 +89,7 @@ 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 Python 3.5 or 3.6 ^(64-bit^) from https://www.python.org/downloads/ echo Unsupported Python bitness. Please install Python 3.6 or higher ^(64-bit^) from https://www.python.org/downloads/
exit /B 1 exit /B 1
) )

View File

@ -94,23 +94,7 @@ if [ -e $INTEL_OPENVINO_DIR/deployment_tools/tools/post_training_optimization_to
fi fi
if [ -z "$python_version" ]; then if [ -z "$python_version" ]; then
if command -v python3.7 >/dev/null 2>&1; then python_version=$(python3 -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')
python_version=3.7
python_bitness=$(python3.7 -c 'import sys; print(64 if sys.maxsize > 2**32 else 32)')
elif command -v python3.6 >/dev/null 2>&1; then
python_version=3.6
python_bitness=$(python3.6 -c 'import sys; print(64 if sys.maxsize > 2**32 else 32)')
elif command -v python3.5 >/dev/null 2>&1; then
python_version=3.5
python_bitness=$(python3.5 -c 'import sys; print(64 if sys.maxsize > 2**32 else 32)')
elif command -v python3.4 >/dev/null 2>&1; then
python_version=3.4
python_bitness=$(python3.4 -c 'import sys; print(64 if sys.maxsize > 2**32 else 32)')
elif command -v python2.7 >/dev/null 2>&1; then
python_version=2.7
elif command -v python >/dev/null 2>&1; then
python_version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
fi
fi fi
OS_NAME="" OS_NAME=""
@ -118,17 +102,23 @@ if command -v lsb_release >/dev/null 2>&1; then
OS_NAME=$(lsb_release -i -s) OS_NAME=$(lsb_release -i -s)
fi fi
python_bitness=$(python3 -c 'import sys; print(64 if sys.maxsize > 2**32 else 32)')
if [ "$python_bitness" != "" ] && [ "$python_bitness" != "64" ] && [ "$OS_NAME" != "Raspbian" ]; then if [ "$python_bitness" != "" ] && [ "$python_bitness" != "64" ] && [ "$OS_NAME" != "Raspbian" ]; then
echo "[setupvars.sh] 64 bitness for Python" $python_version "is requred" echo "[setupvars.sh] 64 bitness for Python" $python_version "is requred"
fi fi
MINIMUM_REQUIRED_PYTHON_VERSION="3.6"
if [[ ! -z "$python_version" && "$(printf '%s\n' "$python_version" "$MINIMUM_REQUIRED_PYTHON_VERSION" | sort -V | head -n 1)" != "$MINIMUM_REQUIRED_PYTHON_VERSION" ]]; then
echo "[setupvars.sh] Unsupported Python version. Please install Python 3.6 or higher (64-bit) from https://www.python.org/downloads/"
fi
if [ ! -z "$python_version" ]; then if [ ! -z "$python_version" ]; then
if [ "$python_version" != "2.7" ]; then # add path to OpenCV API for Python 3.x
# add path to OpenCV API for Python 3.x export PYTHONPATH="$INTEL_OPENVINO_DIR/python/python3:$PYTHONPATH"
export PYTHONPATH="$INTEL_OPENVINO_DIR/python/python3:$PYTHONPATH" if [[ -e $INTEL_OPENVINO_DIR/python/python$python_version ]]; then
# add path to Inference Engine Python API
export PYTHONPATH="$INTEL_OPENVINO_DIR/python/python$python_version:$PYTHONPATH"
fi fi
# add path to Inference Engine Python API
export PYTHONPATH="$INTEL_OPENVINO_DIR/python/python$python_version:$PYTHONPATH"
fi fi
echo "[setupvars.sh] OpenVINO environment initialized" echo "[setupvars.sh] OpenVINO environment initialized"