GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-152680: Check if running in a container/VM in test.pythoninfo by vstinner · Pull Request #152668 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Jun 30, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Log also the "CI" environment variable.

  • Issue: test.pythoninfo: Detect if running in a container or in a virtual machine (VM) #152680

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner vstinner added skip issue skip news labels Jun 30, 2026
@vstinner

vstinner commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

Example on "Ubuntu / build and test (ubuntu-24.04)":

system.boot_id: 7eedccbd-ab3e-48f4-a3f5-eb198989311d
system.in_container: microsoft
system.machine_id: b9d4e40b90bc4dcb974f6d60e5fb946e
system.uptime: 0:02:16

system.in_container: microsoft: Microsoft Hyper-V hypervisor is detected.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
pythongh-152680: Check if running in a container/VM in test.pythoninfo
8b40dff
Log also the "CI" and "container" environment variable.
@vstinner
vstinner force-pushed the pythoninfo_in_container branch from 383367c to 8b40dff Compare June 30, 2026 11:51
@vstinner vstinner removed the skip issue label Jun 30, 2026
@vstinner vstinner changed the title Check if running in a container in test.pythoninfo gh-152680: Check if running in a container/VM in test.pythoninfo Jun 30, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Jun 30, 2026
test.pythoninfo: Detect if running in a container or in a virtual machine (VM) #152680
Closed
vstinner added 5 commits June 30, 2026 14:23
@vstinner
Log run_command() errors
fa61ac8
@vstinner
DEBUG: log run_command() output
5490926
@vstinner
DEBUG; log "sysctl -n hw.model" on Apple
ebe2429
@vstinner
log kern.hv_vmm_present
bf2f058
@vstinner
More bugfixes
f60c855
* Fix ver command
* Fix kern.hv_vmm_present test
* Log also IMAGE_OS_VERSION env var.
* Remove debug messages
@vstinner

vstinner commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

Example on macOS / build and test (macos-26):

system.hardware: VirtualMac2,1
system.uptime: 0:05:19
system.virt: run in a VM (kern.hv_vmm_present is 1)

Virtualization is now detected and the hardware model is also logged.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner added 2 commits June 30, 2026 15:50
@vstinner
Add first_line() function
54b964b
@vstinner
Remove outdated comment
a49567e
@vstinner
vstinner marked this pull request as ready for review June 30, 2026 13:54
@bedevere-app bedevere-app Bot added the awaiting core review label Jun 30, 2026
@vstinner vstinner added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 30, 2026
@bedevere-bot

bedevere-bot commented Jun 30, 2026

Copy link
Copy Markdown

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

Results will be shown at:

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

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 30, 2026
@vstinner

vstinner commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

Tests / Windows (free-threading) / Build and test (arm64, switch-case) (pull_request): Failing after 25m

test_rollover_at_midnight() failed: see #84649 (comment)

FAIL: test_rollover_at_midnight (test.test_logging.TimedRotatingFileHandlerTest.test_rollover_at_midnight)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\a\cpython\cpython\Lib\test\test_logging.py", line 6749, in test_rollover_at_midnight
    self.assertIn(f'testing2 {i}', line)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'testing2 0' not found in '2026-06-30 14:20:24,102 testing1 0\n'
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Jun 30, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

system.virt:

  • AMD64 Alpine Linux PR: system.virt: podman
  • AMD64 CentOS9 NoGIL Refleaks PR: system.virt: amazon
  • AMD64 Debian root PR: system.virt: oracle
  • AMD64 RHEL8 FIPS Only Blake2 Builtin Hash PR: system.virt: kvm
  • s390x RHEL8 LTO + PGO PR: system.virt: zvm
  • WASM Emscripten PR: system.virt: amazon
  • wasm32-wasi PR: system.virt: podman
  • x86 Debian Non-Debug with X PR: system.virt: xen
  • aarch64 RHEL8 LTO + PGO PR: system.virt: kvm

macOS:

  • ARM64 macOS PR: system.hardware: Macmini9,1
  • x86-64 MacOS Intel ASAN NoGIL PR: system.hardware: Macmini8,1

Examples of buildbot workers without system.virt:

  • ARM Raspbian PR
  • ARM64 Raspbian Debug PR
  • iOS ARM64 Simulator PR
  • aarch64 Android PR
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
vstinner enabled auto-merge (squash) June 30, 2026 14:40
@vstinner
Fix os.environ[container]
64a5ced
@vstinner
vstinner disabled auto-merge June 30, 2026 14:43
@vstinner
vstinner enabled auto-merge (squash) June 30, 2026 14:46
@vstinner
vstinner merged commit f1c5363 into python:main Jun 30, 2026
48 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
vstinner deleted the pythoninfo_in_container branch June 30, 2026 15:11
@bedevere-app bedevere-app Bot removed the awaiting core review label Jun 30, 2026
@vstinner vstinner added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Jun 30, 2026
@miss-islington-app

miss-islington-app Bot commented Jun 30, 2026

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app

miss-islington-app Bot commented Jun 30, 2026

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app

miss-islington-app Bot commented Jun 30, 2026

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app

bedevere-app Bot commented Jun 30, 2026

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

bedevere-app Bot commented Jun 30, 2026

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

bedevere-app Bot commented Jun 30, 2026

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jun 30, 2026
vstinner added a commit that referenced this pull request Jun 30, 2026
@miss-islington @vstinner
[3.13] gh-152680: Detect container/VM in test.pythoninfo (GH-152668) (#…
848cb25
…152698)

gh-152680: Detect container/VM in test.pythoninfo (GH-152668)

On Apple, log the hardware model as "system.hardware".

* Log the "CI", "IMAGE_OS_VERSION" and "container"
  environment variables.
* Add run_command() and first_line() functions.
(cherry picked from commit f1c5363)

Co-authored-by: Victor Stinner <[email protected]>
vstinner added a commit that referenced this pull request Jun 30, 2026
@miss-islington @vstinner
[3.14] gh-152680: Detect container/VM in test.pythoninfo (GH-152668) (#…
67d4cbf
…152700)

gh-152680: Detect container/VM in test.pythoninfo (GH-152668)

On Apple, log the hardware model as "system.hardware".

* Log the "CI", "IMAGE_OS_VERSION" and "container"
  environment variables.
* Add run_command() and first_line() functions.
(cherry picked from commit f1c5363)

Co-authored-by: Victor Stinner <[email protected]>
vstinner added a commit that referenced this pull request Jun 30, 2026
@miss-islington @vstinner
[3.15] gh-152680: Detect container/VM in test.pythoninfo (GH-152668) (#…
e9d064f
…152699)

gh-152680: Detect container/VM in test.pythoninfo (GH-152668)

On Apple, log the hardware model as "system.hardware".

* Log the "CI", "IMAGE_OS_VERSION" and "container"
  environment variables.
* Add run_command() and first_line() functions.
(cherry picked from commit f1c5363)

Co-authored-by: Victor Stinner <[email protected]>
maurycy added a commit to maurycy/cpython that referenced this pull request Jul 1, 2026
@maurycy
Merge branch 'main' into maurycy/bye-abba
da7d768
* main: (266 commits)
  pythongh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX is set (pythonGH-151952)
  pythongh-152728: IDLE - move 3 toplevel fix_xyz functions to idlelb.util (python#152729)
  pythongh-152711: Add pythoninfo-build command to Platforms/Android (python#152713)
  pythongh-152715: Add pythoninfo-build command to Platforms/Apple (python#152716)
  pythongh-152433: Windows: enable mmapmodule for UWP (python#152473)
  pythongh-152433: Windows: use GetFileSizeEx instead of GetFileSize for memory mapped files (python#152383)
  pythonGH-81881: Raise `SpecialFileError` for sockets and devices in `shutil.copyfile` (python#142693)
  pythongh-152502: Detect the curses mouse interface and is_* methods portably (pythonGH-152705)
  pythongh-145857: Replace `DELETE_GLOBAL` with `PUSH_NULL; STORE_GLOBAL` (pythonGH-146314)
  pythongh-145854: Replace `DELETE_NAME` with `PUSH_NULL; STORE_NAME` (pythonGH-146006)
  pythongh-152680: Detect container/VM in test.pythoninfo (python#152668)
  pythongh-152682: Fix NULL dereference on OOM in `symtable_visit_type_param_bound_or_default` (python#152684)
  pythongh-151881: Skip tk_inactive negativity check on Windows (pythonGH-152683)
  pythongh-152546: Refactor `mappingproxy.__new__` to use `PyDictProxy_New` (python#152547)
  pythongh-151126: Fix a possible crash during the startup with no memory under `Py_STACKREF_DEBUG` (python#152478)
  pythongh-152635: Raise MemoryError when the lock allocation fails in `_interpchannels.create()` (python#152642)
  pythongh-151029: Fix `test_remote_exec_deleted_static_executable` on static installed builds (pythonGH-152653)
  pythongh-121249: Deprecate using F/D type codes in the struct module (python#152309)
  pythongh-152192: Fix JUMP_BACKWARD passing a truncated oparg to the jit tracer (pythonGH-152382)
  Don't require the `_test{internal}capi` modules in `test_monitoring.py` (python#152311)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@vstinner @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.