Skip to content

gh-152680: Use the _wmi module in test.pythoninfo - #152824

Merged
vstinner merged 9 commits into
python:mainfrom
vstinner:pythoninfo_wmi
Jul 2, 2026
Merged

vstinner merged 9 commits into
python:mainfrom
vstinner:pythoninfo_wmi

Conversation

@vstinner

@vstinner vstinner commented Jul 1, 2026 •

Copy link
Copy Markdown
Member

On Windows, replace wmic command with _wmi module to get the operating system caption and version.

The wmic tool is deprecated since January 2024:
https://techcommunity.microsoft.com/blog/windows-itpro-blog/wmi-command-line-wmic-utility-deprecation-next-steps/4039242

For example, it's no longer installed in Windows images on GitHub Action.

Fix also run_command(): no longer try to spawn a subprocess if the platform doesn't support subprocess. It avoids logging run_command() errors.

On Windows, replace wmic command with _wmi module to get the
operating system caption and version.

The wmic tool is deprecated since January 2024:
https://techcommunity.microsoft.com/blog/windows-itpro-blog/wmi-command-line-wmic-utility-deprecation-next-steps/4039242

For example, it's no longer installed in Windows images on GitHub
Action.

Fix also run_command(): no longer try to spawn a subprocess if the
platform doesn't support subprocess. It avoids logging run_command()
errors.
@vstinner

vstinner commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

I checked test.pythoninfo output of the GitHub Action "Windows / Build and test (x64, tail-call)" job.

Before:

windows.ver: Microsoft Windows [Version 10.0.26100.32995]

With this PR:

windows.ver: Microsoft Windows [Version 10.0.26100.32995]
windows.version: 10.0.26100
windows.version_caption: Microsoft Windows Server 2025 Datacenter

With this change, test.pythoninfo is able to get the operating system caption and version even if wmic is not installed.

@vstinner
vstinner marked this pull request as draft July 1, 2026 22:01
@vstinner

vstinner commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

!buildbot Windows

@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @vstinner for commit bb6099d 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F152824%2Fmerge

The command will test the builders whose names match following regular expression: Windows

The builders matched are:

  • ARM64 Windows Non-Debug PR
  • ARM64 Windows PR
  • AMD64 Windows PGO NoGIL PR
  • AMD64 Windows11 Non-Debug PR
  • AMD64 Windows11 Refleaks PR
  • AMD64 Windows10 PR
  • AMD64 Windows PGO PR
  • AMD64 Windows PGO NoGIL Tailcall PR
  • AMD64 Windows Server 2022 NoGIL PR
  • AMD64 Windows PGO Tailcall PR
@vstinner

vstinner commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

!buildbot Windows

@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @vstinner for commit 1761ea8 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F152824%2Fmerge

The command will test the builders whose names match following regular expression: Windows

The builders matched are:

  • AMD64 Windows11 Non-Debug PR
  • AMD64 Windows11 Refleaks PR
  • AMD64 Windows PGO NoGIL Tailcall PR
  • ARM64 Windows PR
  • AMD64 Windows PGO Tailcall PR
  • AMD64 Windows10 PR
  • AMD64 Windows PGO NoGIL PR
  • AMD64 Windows PGO PR
  • AMD64 Windows Server 2022 NoGIL PR
  • ARM64 Windows Non-Debug PR
@vstinner
vstinner marked this pull request as ready for review July 2, 2026 11:16
@vstinner

vstinner commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

"AMD64 Windows PGO NoGIL PR" buildbot:

system.computer.model: m7i.4xlarge
system.virt: Amazon EC2

GHA "Windows / Build and test (x64, tail-call)" job:

system.virt: Microsoft Hyper-V
@vstinner vstinner changed the title Use the _wmi module in test.pythoninfo Jul 2, 2026
@vstinner
vstinner merged commit 4e4869b into python:main Jul 2, 2026
48 checks passed
@vstinner
vstinner deleted the pythoninfo_wmi branch July 2, 2026 13:00
@vstinner vstinner added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes labels Jul 2, 2026
@vstinner vstinner added the needs backport to 3.15 bugs and security fixes label Jul 2, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Jul 2, 2026

Copy link
Copy Markdown

GH-152888 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Jul 2, 2026
@bedevere-app

bedevere-app Bot commented Jul 2, 2026

Copy link
Copy Markdown

GH-152890 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Jul 2, 2026
@bedevere-app

bedevere-app Bot commented Jul 2, 2026

Copy link
Copy Markdown

GH-152889 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jul 2, 2026
vstinner added a commit that referenced this pull request Jul 2, 2026
…152824) (#152888)

gh-152680: Detect virtualization on Windows in pythoninfo (GH-152824)

Use WMI to detect virtualization on Windows.

Replace wmic command with _wmi module to get the operating system caption and
version.

The wmic tool is deprecated since January 2024:
https://techcommunity.microsoft.com/blog/windows-itpro-blog/wmi-command-line-wmic-utility-deprecation-next-steps/4039242

For example, it's no longer installed in Windows images on GitHub
Action.

Fix also run_command(): no longer try to spawn a subprocess if the
platform doesn't support subprocess. It avoids logging run_command()
errors.
(cherry picked from commit 4e4869b)

Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner added a commit that referenced this pull request Jul 2, 2026
…152824) (#152890)

gh-152680: Detect virtualization on Windows in pythoninfo (GH-152824)

Use WMI to detect virtualization on Windows.

Replace wmic command with _wmi module to get the operating system caption and
version.

The wmic tool is deprecated since January 2024:
https://techcommunity.microsoft.com/blog/windows-itpro-blog/wmi-command-line-wmic-utility-deprecation-next-steps/4039242

For example, it's no longer installed in Windows images on GitHub
Action.

Fix also run_command(): no longer try to spawn a subprocess if the
platform doesn't support subprocess. It avoids logging run_command()
errors.
(cherry picked from commit 4e4869b)

Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner added a commit that referenced this pull request Jul 2, 2026
…152824) (#152889)

gh-152680: Detect virtualization on Windows in pythoninfo (GH-152824)

Use WMI to detect virtualization on Windows.

Replace wmic command with _wmi module to get the operating system caption and
version.

The wmic tool is deprecated since January 2024:
https://techcommunity.microsoft.com/blog/windows-itpro-blog/wmi-command-line-wmic-utility-deprecation-next-steps/4039242

For example, it's no longer installed in Windows images on GitHub
Action.

Fix also run_command(): no longer try to spawn a subprocess if the
platform doesn't support subprocess. It avoids logging run_command()
errors.
(cherry picked from commit 4e4869b)

Co-authored-by: Victor Stinner <vstinner@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants