Skip to content

Commit f44f452

Browse files
authored
[PyOV] Strip minor Python version from t suffix in setupvars scripts (#32636)
### Details: - Python version is being passed to setupvars scripts using `-pyver=3.14t`. Then minor Python version `14t` is being compared to the lower/upper bound, which fails the numerical comparison because there's suddenly a `t` in the equation. ### Tickets: - N/A --------- Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
1 parent 6eeed87 commit f44f452

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

scripts/setupvars/setupvars.bat

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ set "PATH=%OPENVINO_LIB_PATHS%;%PATH%"
6767

6868
:: Check if Python is installed
6969
set PYTHON_VERSION_MAJOR=3
70-
set MIN_REQUIRED_PYTHON_VERSION_MINOR=9
70+
set MIN_REQUIRED_PYTHON_VERSION_MINOR=10
7171
set MAX_SUPPORTED_PYTHON_VERSION_MINOR=14
7272

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

97+
:: Strip non-numeric suffix from minor version (e.g., 14t -> 14)
98+
call :strip_suffix pyversion_minor
99+
97100
if %pyversion_major% equ %PYTHON_VERSION_MAJOR% (
98101
if %pyversion_minor% geq %MIN_REQUIRED_PYTHON_VERSION_MINOR% (
99102
if %pyversion_minor% leq %MAX_SUPPORTED_PYTHON_VERSION_MINOR% (
@@ -126,6 +129,16 @@ if not "%bitness%"=="64" (
126129
set PYTHONPATH=%INTEL_OPENVINO_DIR%\python;%INTEL_OPENVINO_DIR%\python\python3;%PYTHONPATH%
127130
exit /B 0
128131

132+
:strip_suffix
133+
:: Remove non-numeric suffix from a version number variable
134+
:: Usage: call :strip_suffix variable_name
135+
:: Strip 't' suffix (e.g., 14t -> 14)
136+
setlocal enabledelayedexpansion
137+
set "var_value=!%~1!"
138+
for /f "delims=t" %%i in ("!var_value!") do set "var_value=%%i"
139+
endlocal & set "%~1=%var_value%"
140+
exit /B 0
141+
129142
:GetFullPath
130143
SET %2=%~f1
131144

scripts/setupvars/setupvars.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Write-Host "[setupvars] OpenVINO environment initialized"
6363

6464
# Check if Python is installed
6565
$PYTHON_VERSION_MAJOR = 3
66-
$MIN_REQUIRED_PYTHON_VERSION_MINOR = 9
66+
$MIN_REQUIRED_PYTHON_VERSION_MINOR = 10
6767
$MAX_SUPPORTED_PYTHON_VERSION_MINOR = 14
6868

6969
try
@@ -86,7 +86,11 @@ if (-not $python_version)
8686
}
8787
else
8888
{
89-
[int]$installed_python_version_major, [int]$installed_python_version_minor = $python_version.Split('.')
89+
$version_parts = $python_version.Split('.')
90+
$installed_python_version_major = [int]$version_parts[0]
91+
# Strip non-numeric suffix from minor version (e.g., 14t -> 14)
92+
$minor_version_string = $version_parts[1] -replace '[^0-9].*$', ''
93+
$installed_python_version_minor = [int]$minor_version_string
9094
}
9195

9296
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))

scripts/setupvars/setupvars.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ if command -v lsb_release >/dev/null 2>&1; then
100100
fi
101101

102102
PYTHON_VERSION_MAJOR="3"
103-
MIN_REQUIRED_PYTHON_VERSION_MINOR="9"
103+
MIN_REQUIRED_PYTHON_VERSION_MINOR="10"
104104
MAX_SUPPORTED_PYTHON_VERSION_MINOR="14"
105105

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

116+
# Strip non-numeric suffix from minor version (e.g., 14t -> 14)
117+
python_version_minor_numeric="${python_version_minor%%[!0-9]*}"
118+
116119
if [ "$PYTHON_VERSION_MAJOR" != "$python_version_major" ] ||
117-
[ "$python_version_minor" -lt "$MIN_REQUIRED_PYTHON_VERSION_MINOR" ] ||
118-
[ "$python_version_minor" -gt "$MAX_SUPPORTED_PYTHON_VERSION_MINOR" ] ; then
120+
[ "$python_version_minor_numeric" -lt "$MIN_REQUIRED_PYTHON_VERSION_MINOR" ] ||
121+
[ "$python_version_minor_numeric" -gt "$MAX_SUPPORTED_PYTHON_VERSION_MINOR" ] ; then
119122
echo "[setupvars.sh] WARNING: Unsupported Python version ${python_version}. Please install one of Python" \
120123
"${PYTHON_VERSION_MAJOR}.${MIN_REQUIRED_PYTHON_VERSION_MINOR} -" \
121124
"${PYTHON_VERSION_MAJOR}.${MAX_SUPPORTED_PYTHON_VERSION_MINOR} (64-bit) from https://www.python.org/downloads/"

0 commit comments

Comments
 (0)