Skip to content

Commit 65e5969

Browse files
ChatGPT stupid. Instead provide non-environment variable paths.
1 parent 7840f1b commit 65e5969

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

.github/workflows/py_binding.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,20 +129,23 @@ jobs:
129129
run: |
130130
echo "Detecting MSVC STL version..."
131131
132-
$vswhere = "${env:ProgramFiles (x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
133-
$installPath = & "$vswhere" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
132+
$paths = @(
133+
"C:\Program Files\Microsoft Visual Studio",
134+
"C:\Program Files (x86)\Microsoft Visual Studio"
135+
)
134136
135-
if ($installPath) {
136-
$msvcPath = Join-Path $installPath 'VC\Tools\MSVC'
137-
if (Test-Path $msvcPath) {
138-
$latest = Get-ChildItem $msvcPath | Sort-Object Name -Descending | Select-Object -First 1
139-
if ($latest -and $latest.Name -match '^(\d+\.\d+)\.') {
140-
$shortVersion = $matches[1]
141-
echo "Detected STL Version: $shortVersion"
142-
echo "CXX_VERSION=msvc$shortVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
143-
}
137+
$versions = foreach ($base in $paths) {
138+
if (Test-Path $base) {
139+
Get-ChildItem $base -Recurse -Directory -Depth 5 -ErrorAction SilentlyContinue |
140+
Where-Object { $_.FullName -match 'Tools\\MSVC\\(\d+\.\d+)\.' } |
141+
ForEach-Object { if ($_ -match 'Tools\\MSVC\\(\d+\.\d+)\.') { $matches[1] } }
144142
}
145143
}
144+
145+
$stlVersion = $versions | Sort-Object -Descending -Unique | Select-Object -First 1
146+
147+
echo "Detected STL Version: $stlVersion"
148+
echo "CXX_VERSION=msvc$stlVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
146149
147150
- name: Extract C++ Standard Library Version (Linux & MacOS)
148151
if: matrix.os != 'windows-latest'

0 commit comments

Comments
 (0)