Skip to content

Commit

Permalink
[Scripts] setupvars.bat: Added logic for passing '-pyver' option (#4026)
Browse files Browse the repository at this point in the history
* setupvars.bat: Added logic for passing '-pyver' option as we already have in Linux* setupvars

* setupvars.bat: Fixed python_version name in echo
  • Loading branch information
artanokhov authored Jan 27, 2021
1 parent b90f908 commit 344494a
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions scripts/setupvars/setupvars.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,27 @@
:: 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

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"
Expand Down Expand Up @@ -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" (
Expand Down

0 comments on commit 344494a

Please sign in to comment.