fix: windows core count from powershell#2108
Conversation
…th wmic fallback Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2108 +/- ##
==========================================
+ Coverage 60.65% 60.69% +0.04%
==========================================
Files 164 164
Lines 20584 20598 +14
Branches 3579 3580 +1
==========================================
+ Hits 12485 12502 +17
+ Misses 7224 7220 -4
- Partials 875 876 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| def _physical_cores_from_powershell(self) -> int | None: | ||
| # wmic was removed in Windows 11 24H2; use PowerShell/CimInstance instead. | ||
| # powershell.exe (Windows PowerShell 5.1) ships with all Windows 10/11 installs. | ||
| import subprocess |
There was a problem hiding this comment.
| import subprocess |
subprocess is already imported at the top level.
There was a problem hiding this comment.
Pull request overview
This PR addresses Windows 11 24H2 environments where wmic is no longer present by updating Rez’s Windows physical core detection to prefer a PowerShell/CIM-based query, while retaining wmic as a fallback for older Windows builds.
Changes:
- Added
WindowsPlatform._physical_cores_from_powershell()usingGet-CimInstance/Measure-Objectand updated_physical_cores()to prefer it before falling back to WMIC. - Clarified WMIC helper intent as a fallback for older Windows versions.
- Added Windows-only unit tests covering PowerShell/WMIC parsing and the fallback chain, plus basic smoke checks for
logical_cores/physical_cores.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/rez/utils/platform_.py |
Adds PowerShell-based physical core detection and prefers it over WMIC with WMIC retained as fallback. |
src/rez/tests/test_utils.py |
Adds Windows-only tests for the new PowerShell core counting helper and fallback behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| def _physical_cores(self) -> int | None: | ||
| return self._physical_cores_from_wmic() | ||
| return self._physical_cores_from_powershell() or self._physical_cores_from_wmic() |
Closes #2029 .
Explanation:
wmicwas removed as a default install in Windows 11 24H2, causing rez to fail at startup when physical core count is computed.Fix:
Replace it with a
PowerShell/Get-CimInstanceequivalent -powershell.exe(Windows PowerShell 5.1) ships with all Windows 10/11 installs and is guaranteed available. The oldwmicpath is retained as a fallback for older Windows builds.Disclosure:
This PR was AI-assisted with Claude Code, Sonnet 4.6, primarily for diagnostics, logic-tracing, documentation and edge-case verification.