Skip to content

fix: windows core count from powershell#2108

Open
maxnbk wants to merge 2 commits into
AcademySoftwareFoundation:mainfrom
maxnbk:fix/windows-core-count-from-powershell
Open

fix: windows core count from powershell#2108
maxnbk wants to merge 2 commits into
AcademySoftwareFoundation:mainfrom
maxnbk:fix/windows-core-count-from-powershell

Conversation

@maxnbk
Copy link
Copy Markdown
Contributor

@maxnbk maxnbk commented May 15, 2026

Closes #2029 .

Explanation:

wmic was 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-CimInstance equivalent - powershell.exe (Windows PowerShell 5.1) ships with all Windows 10/11 installs and is guaranteed available. The old wmic path 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.

maxnbk added 2 commits May 15, 2026 07:01
…th wmic fallback

Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
Signed-off-by: Stephen Mackenzie <maxnbk@users.noreply.github.com>
@maxnbk maxnbk requested a review from a team as a code owner May 15, 2026 11:04
@maxnbk maxnbk added the devdays26 ASWF Dev Days 2026 label May 15, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.69%. Comparing base (d415b96) to head (f92b52e).
⚠️ Report is 2 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import subprocess

subprocess is already imported at the top level.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() using Get-CimInstance/Measure-Object and 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.

Comment thread src/rez/utils/platform_.py

def _physical_cores(self) -> int | None:
return self._physical_cores_from_wmic()
return self._physical_cores_from_powershell() or self._physical_cores_from_wmic()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devdays26 ASWF Dev Days 2026

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows 11 - Missing wmic blocks rez from working

3 participants