Skip to content

Commit d2ee3f1

Browse files
Just check paths on Windows.
1 parent 9271c00 commit d2ee3f1

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

.github/workflows/py_binding.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,25 @@ jobs:
127127
if: matrix.os == 'windows-latest'
128128
shell: powershell
129129
run: |
130-
echo "Detecting STL version using $env:CXX"
130+
echo "Detecting MSVC STL version..."
131131
132-
$cxx_version = & $env:CXX -dM -E -x c++ NUL 2>$null | Select-String '_MSC_VER' | ForEach-Object {
133-
if ($_ -match '_MSC_VER\s+(\d+)') {
134-
"msvc$($matches[1])"
132+
$paths = @(
133+
"$env:ProgramFiles\Microsoft Visual Studio",
134+
"$env:ProgramFiles (x86)\Microsoft Visual Studio"
135+
)
136+
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] } }
135142
}
136143
}
137144
138-
echo "CXX_VERSION=$cxx_version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
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
139149
140150
- name: Extract C++ Standard Library Version (Linux & MacOS)
141151
if: matrix.os != 'windows-latest'

0 commit comments

Comments
 (0)