This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add test.pythoninfo
Type: enhancement Stage: resolved
Components: Tests Versions: Python 3.7, Python 3.6, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Nir Soffer, berker.peksag, ncoghlan, pablogsal, serhiy.storchaka, terry.reedy, vstinner
Priority: normal Keywords:

Created on 2017-07-07 14:48 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pythoninfo.py vstinner, 2017-07-07 14:48
Pull Requests
URL Status Linked Edit
PR 3075 merged vstinner, 2017-08-11 15:18
PR 2618 closed berker.peksag, 2017-08-11 22:29
PR 3120 merged vstinner, 2017-08-17 14:57
PR 3121 merged vstinner, 2017-08-17 16:33
PR 3130 merged vstinner, 2017-08-18 09:45
PR 3134 merged vstinner, 2017-08-18 14:43
PR 3174 merged vstinner, 2017-08-21 21:55
PR 3175 merged vstinner, 2017-08-21 22:56
Messages (30)
msg297885 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-07-07 14:48
While discussing how to dump the readline version in regrtest or test_readline in bpo-29854, I proposed to add a new buildbot step to dump any kinds of debug information. It would avoid to pollute test output with useless information. For example, while the hash implementation is useful for unit tests on the hash function, I dislike always dumping it in the regrtest header.

The idea would be to get a phpinfo-like report:
http://php.net/phpinfo

We can start with an hardcoded list using "try: import xxx except ImportError: pass else: ...", but later we may it more "pluggable" somehow?

Maybe define a protocol (function with a specific name, maybe a private function?) for each module, add a command which can dump info on a single module, or all modules.

Maybe start with an hardcoded list of modules, but later discover automatically all stdlib modules?

I don't expect a regular list of information, but more like a long key-value list.

Attached pythoninfo.py is an example of such script. It works on Python 2.7-3.7. Example of Python 3.7 output on my Linux PC:
---
cpu_count: 4
cwd: /home/haypo/prog/GIT/misc/python
filesystem_encoding: utf-8
filesystem_errors: surrogateescape
gdb_version: GNU gdb (GDB) Fedora 7.12.1-48.fc25
hash algorithm: ('siphash24', '64bit')
locale_encoding: UTF-8
platform: Linux-4.11.6-201.fc25.x86_64-x86_64-with-fedora-25-Twenty_Five
python_implementation: CPython
readline_library_version: 6.3
readline_runtime_version: 0x603
readline_version: 0x603
sys.byteorder: little
sys.flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0)
sys.maxsize: 9223372036854775807
sys.version: 3.7.0a0 (heads/testcapi_stack_pointer_master:81dd3fb, Jul  6 2017, 13:10:36)  [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]
tcl_version: 8.6
---

Later, we may add a JSON output format, to allow to collect informations of all buildbots. For example, check all tested readline versions.
msg297888 - (view) Author: Nir Soffer (Nir Soffer) Date: 2017-07-07 14:57
I like the idea, may be also useful in https://github.com/sosreport/sos/blob/master/sos/plugins/python.py
msg297891 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-07-07 15:08
Something like the CLI of modules site, sysconfig and platform?

Note that there are two versions: the version with which the interpreter is build, and the version of the dynamic library.
msg300168 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-11 15:31
I wrote https://github.com/python/cpython/pull/3075 to add "python3 -m test.pythoninfo". I chose to add the script into Lib/test/ to notice users that it's design for Python internal usage, for Python tests.

I modified scripts running tests on our CI to also run pythoninfo, and then also started to cleanup ("simplify") the regrtest header (remove information rarely useful).
msg300169 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-11 15:35
Nir Soffer: "I like the idea, may be also useful in https://github.com/sosreport/sos/blob/master/sos/plugins/python.py"

It's hard to guess which kinds of informations are needed. My use case is to debug failing tests on the Python CIs. Other use cases may want other kinds of information.

For example, my perf module also a "python3 -m perf collect_metadata" which has a similar goal but reads also information about the CPU: CPU configuration, model, temperature, etc. I don't think that these information are useful for Python tests.


Serhiy Storchaka: "Note that there are two versions: the version with which the interpreter is build, and the version of the dynamic library."

Sorry, version of what? The readline module has two versions, my proposed test.pythoninfo tool saves both. Depending on the failing test, you need one version or the other, or both.

The purpose of pythoninfo is to be able to log a long list of informations, without after to care if it is useful or not in general ;-)
msg300183 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-08-11 22:30
Two things:

1. I've just closed  PR 2618 as the scope of this issue is broader than my PR.
2. Could you also add version information of sqlite3?
msg300215 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-08-13 09:12
> Sorry, version of what?

Versions of any external library. Python can be built with headers of one version, but dynamically load the library of other version.

For example TCL_VERSION and TK_VERSION are static versions (they should be equal in modern Tcl/Tk), and Tcl command "info patchlevel" returns the dynamic version. In the readline module _READLINE_VERSION is header version, _READLINE_RUNTIME_VERSION and _READLINE_LIBRARY_VERSION are runtime versions. In the zlib module ZLIB_VERSION is header version, ZLIB_RUNTIME_VERSION is runtime version.
msg300347 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-16 11:09
Berker: "2. Could you also add version information of sqlite3?"

Sure, done.
msg300425 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-17 14:02
Serhiy: "For example TCL_VERSION and TK_VERSION are static versions (they should be equal in modern Tcl/Tk), and Tcl command "info patchlevel" returns the dynamic version."

Ok, I added tkinter.patchlevel info which calls "info patchlevel".


Serhiy: "In the readline module _READLINE_VERSION is header version, _READLINE_RUNTIME_VERSION and _READLINE_LIBRARY_VERSION are runtime versions."

The 3 variables are stored.


Serhiy: "In the zlib module ZLIB_VERSION is header version, ZLIB_RUNTIME_VERSION is runtime version."

I just added the 2 variables.
msg300429 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-17 14:40
New changeset b907abc88589f7bea52c5afe172ececc6edcda70 by Victor Stinner in branch 'master':
bpo-30871: Add test.pythoninfo (#3075)
https://github.com/python/cpython/commit/b907abc88589f7bea52c5afe172ececc6edcda70
msg300431 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-17 15:00
I created https://github.com/python/cpython/pull/3120 to add "make pythoninfo" because it's more tricky than what I expected to run "./python -m test.pythoninfo" on buildbots. Depending if Python is built with shared library, depending on the OS (./python, or ./python.exe for macOS?), ... the command is different.

I plan to backport Lib/test/pythoninfo.py and "make pythoninfo" to Python 2.7 and 3.6 to ease debug on all supported Python branches.
msg300433 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-17 15:04
> I plan to backport Lib/test/pythoninfo.py and "make pythoninfo" to Python 2.7 and 3.6 to ease debug on all supported Python branches.

Oh, but I will first only run pythoninfo on buildbot for the master branch, since I expect surprises depending on the platform :-) Once everything is fine, I will backport the enhancement to other branches.
msg300448 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-08-17 17:36
python -m test.pythoninfo crashes for me on Win10, debug32, but I don't think it is the fault of pythoninfo.  See #31288.
msg300456 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-17 20:13
New changeset f6ebd838f00b4c211c72d85ee49749e910cd3afe by Victor Stinner in branch 'master':
bpo-30871: pythoninfo: add expat and _decimal (#3121)
https://github.com/python/cpython/commit/f6ebd838f00b4c211c72d85ee49749e910cd3afe
msg300479 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-18 09:31
New changeset a3a01a2fceab2188b282ab9911f79c99a4c32273 by Victor Stinner in branch 'master':
bpo-30871: Add "make pythoninfo" (#3120)
https://github.com/python/cpython/commit/a3a01a2fceab2188b282ab9911f79c99a4c32273
msg300480 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-18 10:08
New changeset ad7eaed54382b346784e51a6f0122ce81e8842b5 by Victor Stinner in branch 'master':
bpo-30871: pythoninfo: more sys, os, time data (#3130)
https://github.com/python/cpython/commit/ad7eaed54382b346784e51a6f0122ce81e8842b5
msg300481 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2017-08-18 10:26
If we end up deciding some of this information might be useful to end users as well, it would be reasonable to extend "python -m sysconfig" to report it, perhaps with the extra imports gated behind a command line option.
msg300482 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-18 10:33
Nick Coghlan: "If we end up deciding some of this information might be useful to end users as well, it would be reasonable to extend "python -m sysconfig" to report it, perhaps with the extra imports gated behind a command line option."

Designing such tool is a can of worm. Everybody can have different expectation, different information. IMHO PyPI is a better home for a more general tool. I prefer to keep test.pythoninfo specialized to debug failures on CIs (Travis CI, AppVeyor, buildbots).

For test.pythoninfo, I'm mostly interested to get plaintext output right now, and JSON output later, to correlate information. For example, be able to say which readline versions are tested on all buildbots for one Python branch.

Moreover, I would like to add test.pythoninfo to Python 2.7 and 3.6. It wouldn't be doable if the tool would be in the stdlib, since these branches don't accept new features ;-)
msg300497 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-18 13:42
I applied Segev Finer's fix for bpo-30121 (commit 4d3851727fb82195e4995c6064b0b2d6cbc031c4
), so test.pythoninfo now works properly on Windows.

I added a new pythoninfo step to Unix and Windows buildbots. It seems like everything is fine. I will wait a few days before starting to backport to 3.6, and then 2.7, just in case ;-) Backporting pythoninfo will likely have to wait until bpo-30121 is fixed in Python 3.6 as well.
msg300507 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-18 15:30
New changeset 92b1f90143286385c0ff5be98d3721b90580a912 by Victor Stinner in branch 'master':
bpo-31231: Fix pythoninfo in Travis config (#3134)
https://github.com/python/cpython/commit/92b1f90143286385c0ff5be98d3721b90580a912
msg300657 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-21 22:17
New changeset 29d007bb670b486788f73c2d742b0ad0b679ff13 by Victor Stinner in branch '3.6':
[3.6] bpo-30871: Add test.pythoninfo (#3174)
https://github.com/python/cpython/commit/29d007bb670b486788f73c2d742b0ad0b679ff13
msg300659 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-21 22:37
Ok, pythoninfo is now enabled on Python 3.6 as well.
msg300664 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-22 01:40
New changeset cce1cb9180dd9143c5b2ce094a52c555b42c7aa8 by Victor Stinner in branch '2.7':
bpo-30871: Add test.pythoninfo (#3174) (#3175)
https://github.com/python/cpython/commit/cce1cb9180dd9143c5b2ce094a52c555b42c7aa8
msg300665 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-22 02:35
I also added pythoninfo to Python 2.7. I made minor adjustements for Python 2.7, like accept (int, long) for integers, remove info only available on Python 3, and add sys.maxint.
msg300703 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-22 15:17
Crap, everything is fine on all CIs... except of a single Windows buildbot using Visual Studio 2010 which doesn't produce the required python.bat:

http://buildbot.python.org/all/builders/AMD64%20Windows7%20SP1%20VS9.0%202.7/builds/187/steps/pythoninfo/logs/stdio
msg300705 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-22 15:52
I created bpo-31260: [2.7] Enhance PC/VS9.0/ project to produce python.bat, as PCbuild/
msg300710 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-08-22 16:09
I modified the buildbot configuration so a pythoninfo failure marks the build as WARNINGS instead of FAILED:
https://github.com/python/buildmaster-config/commit/3866fac355b91d9d56507c345992fad2169759b4

But I'm not sure that it works :-/ I forced a build, but the build was marked as FAILED.
msg301750 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-09-08 22:46
pythoninfo is now available on all buildbots, including Python 2.7 VS9.0 buildbots:
https://bugs.python.org/issue31260#msg301747
msg323445 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2018-08-12 15:54
pythoninfo is failing on several buildbots:


https://buildbot.python.org/all/#/builders/102/builds/55
https://buildbot.python.org/all/#/builders/79/builds/237
https://buildbot.python.org/all/#/builders/112/builds/161
https://buildbot.python.org/all/#/builders/118/builds/164
https://buildbot.python.org/all/#/builders/56/builds/105
https://buildbot.python.org/all/#/builders/18/builds/109

Example error:

./python -m test.pythoninfo
ERROR: collect_gdb() failed
Traceback (most recent call last):
  File "/usr/home/buildbot/python/2.7.koobs-freebsd-current.nondebug/build/Lib/test/pythoninfo.py", line 561, in collect_info
    collect_func(info_add)
  File "/usr/home/buildbot/python/2.7.koobs-freebsd-current.nondebug/build/Lib/test/pythoninfo.py", line 300, in collect_gdb
    version = version.splitlines()[0]
IndexError: list index out of range
msg323447 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2018-08-12 15:59
All of these failures seems related to `collect_gdb`  I am going to open a new issue:

https://bugs.python.org/issue34388

Please, re-open this one if you think is better to have both open.
History
Date User Action Args
2022-04-11 14:58:48adminsetgithub: 75054
2018-08-12 15:59:59pablogsalsetstatus: open -> closed

messages: + msg323447
2018-08-12 15:55:01pablogsalsetstatus: closed -> open
2018-08-12 15:54:57pablogsalsetnosy: + pablogsal
messages: + msg323445
2017-09-08 22:46:43vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg301750
2017-08-22 16:09:03vstinnersetmessages: + msg300710
2017-08-22 15:52:57vstinnersetmessages: + msg300705
2017-08-22 15:17:27vstinnersetstatus: closed -> open
resolution: fixed -> (no value)
messages: + msg300703
2017-08-22 02:35:48vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg300665

stage: patch review -> resolved
2017-08-22 01:40:30vstinnersetmessages: + msg300664
2017-08-21 22:56:05vstinnersetpull_requests: + pull_request3212
2017-08-21 22:37:45vstinnersetmessages: + msg300659
2017-08-21 22:17:17vstinnersetmessages: + msg300657
2017-08-21 21:55:14vstinnersetpull_requests: + pull_request3210
2017-08-18 15:30:55vstinnersetmessages: + msg300507
2017-08-18 14:43:15vstinnersetpull_requests: + pull_request3169
2017-08-18 13:42:12vstinnersetmessages: + msg300497
2017-08-18 13:40:31vstinnersettitle: Add a "python info" command somewhere to dump versions of all dependencies -> Add test.pythoninfo
2017-08-18 10:33:00vstinnersetmessages: + msg300482
2017-08-18 10:26:04ncoghlansetnosy: + ncoghlan
messages: + msg300481
2017-08-18 10:08:49vstinnersetmessages: + msg300480
2017-08-18 09:45:56vstinnersetpull_requests: + pull_request3164
2017-08-18 09:31:57vstinnersetmessages: + msg300479
2017-08-17 20:13:15vstinnersetmessages: + msg300456
2017-08-17 17:36:56terry.reedysetnosy: + terry.reedy
messages: + msg300448
2017-08-17 16:33:26vstinnersetpull_requests: + pull_request3160
2017-08-17 15:04:47vstinnersetmessages: + msg300433
2017-08-17 15:00:20vstinnersetmessages: + msg300431
versions: + Python 2.7, Python 3.6
2017-08-17 14:57:56vstinnersetpull_requests: + pull_request3158
2017-08-17 14:40:53vstinnersetmessages: + msg300429
2017-08-17 14:02:27vstinnersetmessages: + msg300425
2017-08-16 11:09:29vstinnersetmessages: + msg300347
2017-08-13 09:12:19serhiy.storchakasetmessages: + msg300215
2017-08-11 22:30:31berker.peksagsetnosy: + berker.peksag

messages: + msg300183
stage: patch review
2017-08-11 22:29:51berker.peksagsetpull_requests: + pull_request3116
2017-08-11 15:35:41vstinnersetmessages: + msg300169
2017-08-11 15:31:45vstinnersetmessages: + msg300168
2017-08-11 15:18:38vstinnersetpull_requests: + pull_request3112
2017-07-07 15:08:18serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg297891
2017-07-07 14:57:24Nir Soffersetnosy: + Nir Soffer
messages: + msg297888
2017-07-07 14:48:35vstinnercreate