Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion scripts/setupvars/setupvars.bat
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ set "PATH=%OPENVINO_LIB_PATHS%;%PATH%"

:: Check if Python is installed
set PYTHON_VERSION_MAJOR=3
set MIN_REQUIRED_PYTHON_VERSION_MINOR=9
set MIN_REQUIRED_PYTHON_VERSION_MINOR=10
set MAX_SUPPORTED_PYTHON_VERSION_MINOR=14

python --version 2>NUL
Expand All @@ -94,6 +94,9 @@ for /F "tokens=1,2 delims=. " %%a in ("%python_version%") do (
set pyversion_minor=%%b
)

:: Strip non-numeric suffix from minor version (e.g., 14t -> 14)
call :strip_suffix pyversion_minor

if %pyversion_major% equ %PYTHON_VERSION_MAJOR% (
if %pyversion_minor% geq %MIN_REQUIRED_PYTHON_VERSION_MINOR% (
if %pyversion_minor% leq %MAX_SUPPORTED_PYTHON_VERSION_MINOR% (
Expand Down Expand Up @@ -126,6 +129,16 @@ if not "%bitness%"=="64" (
set PYTHONPATH=%INTEL_OPENVINO_DIR%\python;%INTEL_OPENVINO_DIR%\python\python3;%PYTHONPATH%
exit /B 0

:strip_suffix
:: Remove non-numeric suffix from a version number variable
:: Usage: call :strip_suffix variable_name
:: Strip 't' suffix (e.g., 14t -> 14)
setlocal enabledelayedexpansion
set "var_value=!%~1!"
for /f "delims=t" %%i in ("!var_value!") do set "var_value=%%i"
endlocal & set "%~1=%var_value%"
exit /B 0

:GetFullPath
SET %2=%~f1

Expand Down
8 changes: 6 additions & 2 deletions scripts/setupvars/setupvars.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Write-Host "[setupvars] OpenVINO environment initialized"

# Check if Python is installed
$PYTHON_VERSION_MAJOR = 3
$MIN_REQUIRED_PYTHON_VERSION_MINOR = 9
$MIN_REQUIRED_PYTHON_VERSION_MINOR = 10
$MAX_SUPPORTED_PYTHON_VERSION_MINOR = 14

try
Expand All @@ -86,7 +86,11 @@ if (-not $python_version)
}
else
{
[int]$installed_python_version_major, [int]$installed_python_version_minor = $python_version.Split('.')
$version_parts = $python_version.Split('.')
$installed_python_version_major = [int]$version_parts[0]
# Strip non-numeric suffix from minor version (e.g., 14t -> 14)
$minor_version_string = $version_parts[1] -replace '[^0-9].*$', ''
$installed_python_version_minor = [int]$minor_version_string
}

if (-not ($PYTHON_VERSION_MAJOR -eq $installed_python_version_major -and $installed_python_version_minor -ge $MIN_REQUIRED_PYTHON_VERSION_MINOR -and $installed_python_version_minor -le $MAX_SUPPORTED_PYTHON_VERSION_MINOR))
Expand Down
9 changes: 6 additions & 3 deletions scripts/setupvars/setupvars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ if command -v lsb_release >/dev/null 2>&1; then
fi

PYTHON_VERSION_MAJOR="3"
MIN_REQUIRED_PYTHON_VERSION_MINOR="9"
MIN_REQUIRED_PYTHON_VERSION_MINOR="10"
MAX_SUPPORTED_PYTHON_VERSION_MINOR="14"

check_python_version () {
Expand All @@ -113,9 +113,12 @@ check_python_version () {
python_version_minor=$( python3 -c "import sys; print(str(\"${python_version}\".split('.')[1]))" )
fi

# Strip non-numeric suffix from minor version (e.g., 14t -> 14)
python_version_minor_numeric="${python_version_minor%%[!0-9]*}"

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
[ "$python_version_minor_numeric" -lt "$MIN_REQUIRED_PYTHON_VERSION_MINOR" ] ||
[ "$python_version_minor_numeric" -gt "$MAX_SUPPORTED_PYTHON_VERSION_MINOR" ] ; then
echo "[setupvars.sh] WARNING: Unsupported Python version ${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/"
Expand Down
Loading