-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_python.ps1
More file actions
34 lines (28 loc) · 932 Bytes
/
get_python.ps1
File metadata and controls
34 lines (28 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# SecureEV-OTA: Python Path Discovery Utility
# Usage: $VENV_PYTHON = . .\get_python.ps1
function Get-PythonPath {
$venvPaths = @(
".\.venv\Scripts\python.exe",
".\venv\Scripts\python.exe",
".\.venv\bin\python",
".\venv\bin\python"
)
foreach ($path in $venvPaths) {
$absPath = Join-Path (Get-Location) $path
if (Test-Path $absPath) {
return $absPath
}
}
# Fallback to system python, filtering out potentially problematic MSYS2 interpreters
$sysPythons = Get-Command python.exe -All -ErrorAction SilentlyContinue | Where-Object {
$_.Source -notlike "*msys64*" -and $_.Source -notlike "*mingw*"
}
if ($sysPythons) {
return $sysPythons[0].Source
}
return "python"
}
# If this script is run directly, just output the path
if ($MyInvocation.InvocationName -ne '.') {
Get-PythonPath
}