Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[PyOV] Strip minor Python version from `t` suffix in setupvars scripts (#32636)

Przemyslaw Wysockif44f45224053
diff --git a/scripts/setupvars/setupvars.bat b/scripts/setupvars/setupvars.bat
index 2d187460501..facb951316b 100644
--- a/scripts/setupvars/setupvars.bat
+++ b/scripts/setupvars/setupvars.bat
@@ -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
@@ -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% (
@@ -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
diff --git a/scripts/setupvars/setupvars.ps1 b/scripts/setupvars/setupvars.ps1
index 06d9dc18590..764df4c4813 100644
--- a/scripts/setupvars/setupvars.ps1
+++ b/scripts/setupvars/setupvars.ps1
@@ -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
@@ -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))
diff --git a/scripts/setupvars/setupvars.sh b/scripts/setupvars/setupvars.sh
index 82685c34c40..b73d65f1882 100755
--- a/scripts/setupvars/setupvars.sh
+++ b/scripts/setupvars/setupvars.sh
@@ -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 () {
@@ -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/"