[Scripts] setupvars.bat: Added logic for passing '-pyver' option (#4026)

* setupvars.bat: Added logic for passing '-pyver' option as we already have in Linux* setupvars

* setupvars.bat: Fixed python_version name in echo
This commit is contained in:
Artyom Anokhov 2021-01-27 12:51:55 +03:00 committed by GitHub
parent b90f908c58
commit 344494a935
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,8 @@
:: See the License for the specific language governing permissions and
:: limitations under the License.
setlocal enableDelayedExpansion
set ROOT=%~dp0
call :GetFullPath "%ROOT%\.." ROOT
set SCRIPT_NAME=%~nx0
@ -21,6 +23,18 @@ set SCRIPT_NAME=%~nx0
set "INTEL_OPENVINO_DIR=%ROOT%"
set "INTEL_CVSDK_DIR=%INTEL_OPENVINO_DIR%"
:: command line arguments parsing
:input_arguments_loop
if not "%1"=="" (
if "%1"=="-pyver" (
set python_version=%2
echo python_version = !python_version!
shift
)
shift
goto :input_arguments_loop
)
:: OpenCV
if exist "%INTEL_OPENVINO_DIR%\opencv\setupvars.bat" (
call "%INTEL_OPENVINO_DIR%\opencv\setupvars.bat"
@ -68,14 +82,16 @@ if errorlevel 1 (
exit /B 1
)
:: Check Python version
for /F "tokens=* USEBACKQ" %%F IN (`python --version 2^>^&1`) DO (
set pyversion=%%F
:: Check Python version if user did not pass -pyver
if not defined python_version (
for /F "tokens=* USEBACKQ" %%F IN (`python -c "import sys; print(str(sys.version_info[0])+'.'+str(sys.version_info[1]))"`) DO (
set python_version=%%F
)
)
for /F "tokens=1,2,3 delims=. " %%a in ("%pyversion%") do (
set pyversion_major=%%b
set pyversion_minor=%%c
for /F "tokens=1,2 delims=. " %%a in ("%python_version%") do (
set pyversion_major=%%a
set pyversion_minor=%%b
)
if "%pyversion_major%" geq "3" (