Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test.pythoninfo #75054

Closed
vstinner opened this issue Jul 7, 2017 · 30 comments
Closed

Add test.pythoninfo #75054

vstinner opened this issue Jul 7, 2017 · 30 comments
Labels
3.7 (EOL) end of life tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@vstinner
Copy link
Member

vstinner commented Jul 7, 2017

BPO 30871
Nosy @terryjreedy, @ncoghlan, @vstinner, @berkerpeksag, @serhiy-storchaka, @pablogsal
PRs
  • bpo-30871: Add test.pythoninfo #3075
  • bpo-29854: Print readline version information when running test suite #2618
  • bpo-30871: Add "make pythoninfo" #3120
  • bpo-30871: pythoninfo: add expat and _decimal #3121
  • bpo-30871: pythoninfo: more sys, os, time data #3130
  • bpo-31231: Fix pythoninfo in Travis config #3134
  • [3.6] bpo-30871: Add test.pythoninfo #3174
  • [2.7] bpo-30871: Add test.pythoninfo (#3174) #3175
  • Files
  • pythoninfo.py
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2018-08-12.15:59:59.056>
    created_at = <Date 2017-07-07.14:48:35.518>
    labels = ['3.7', 'type-feature', 'tests']
    title = 'Add test.pythoninfo'
    updated_at = <Date 2018-08-12.15:59:59.054>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2018-08-12.15:59:59.054>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-08-12.15:59:59.056>
    closer = 'pablogsal'
    components = ['Tests']
    creation = <Date 2017-07-07.14:48:35.518>
    creator = 'vstinner'
    dependencies = []
    files = ['46994']
    hgrepos = []
    issue_num = 30871
    keywords = []
    message_count = 30.0
    messages = ['297885', '297888', '297891', '300168', '300169', '300183', '300215', '300347', '300425', '300429', '300431', '300433', '300448', '300456', '300479', '300480', '300481', '300482', '300497', '300507', '300657', '300659', '300664', '300665', '300703', '300705', '300710', '301750', '323445', '323447']
    nosy_count = 7.0
    nosy_names = ['terry.reedy', 'ncoghlan', 'vstinner', 'berker.peksag', 'serhiy.storchaka', 'Nir Soffer', 'pablogsal']
    pr_nums = ['3075', '2618', '3120', '3121', '3130', '3134', '3174', '3175']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue30871'
    versions = ['Python 2.7', 'Python 3.6', 'Python 3.7']

    @vstinner
    Copy link
    Member Author

    vstinner commented Jul 7, 2017

    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.

    @vstinner vstinner added 3.7 (EOL) end of life tests Tests in the Lib/test dir type-feature A feature request or enhancement labels Jul 7, 2017
    @NirSoffer
    Copy link
    Mannequin

    NirSoffer mannequin commented Jul 7, 2017

    I like the idea, may be also useful in https://github.com/sosreport/sos/blob/master/sos/plugins/python.py

    @serhiy-storchaka
    Copy link
    Member

    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.

    @vstinner
    Copy link
    Member Author

    I wrote #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).

    @vstinner
    Copy link
    Member Author

    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 ;-)

    @berkerpeksag
    Copy link
    Member

    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?

    @serhiy-storchaka
    Copy link
    Member

    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.

    @vstinner
    Copy link
    Member Author

    Berker: "2. Could you also add version information of sqlite3?"

    Sure, done.

    @vstinner
    Copy link
    Member Author

    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.

    @vstinner
    Copy link
    Member Author

    New changeset b907abc by Victor Stinner in branch 'master':
    bpo-30871: Add test.pythoninfo (bpo-3075)
    b907abc

    @vstinner
    Copy link
    Member Author

    I created #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.

    @vstinner
    Copy link
    Member Author

    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.

    @terryjreedy
    Copy link
    Member

    python -m test.pythoninfo crashes for me on Win10, debug32, but I don't think it is the fault of pythoninfo. See bpo-31288.

    @vstinner
    Copy link
    Member Author

    New changeset f6ebd83 by Victor Stinner in branch 'master':
    bpo-30871: pythoninfo: add expat and _decimal (bpo-3121)
    f6ebd83

    @vstinner
    Copy link
    Member Author

    New changeset a3a01a2 by Victor Stinner in branch 'master':
    bpo-30871: Add "make pythoninfo" (bpo-3120)
    a3a01a2

    @vstinner
    Copy link
    Member Author

    New changeset ad7eaed by Victor Stinner in branch 'master':
    bpo-30871: pythoninfo: more sys, os, time data (bpo-3130)
    ad7eaed

    @ncoghlan
    Copy link
    Contributor

    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.

    @vstinner
    Copy link
    Member Author

    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 ;-)

    @vstinner vstinner changed the title Add a "python info" command somewhere to dump versions of all dependencies Add test.pythoninfo Aug 18, 2017
    @vstinner
    Copy link
    Member Author

    I applied Segev Finer's fix for bpo-30121 (commit 4d38517
    ), 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.

    @vstinner
    Copy link
    Member Author

    New changeset 92b1f90 by Victor Stinner in branch 'master':
    bpo-31231: Fix pythoninfo in Travis config (bpo-3134)
    92b1f90

    @vstinner
    Copy link
    Member Author

    New changeset 29d007b by Victor Stinner in branch '3.6':
    [3.6] bpo-30871: Add test.pythoninfo (bpo-3174)
    29d007b

    @vstinner
    Copy link
    Member Author

    Ok, pythoninfo is now enabled on Python 3.6 as well.

    @vstinner
    Copy link
    Member Author

    New changeset cce1cb9 by Victor Stinner in branch '2.7':
    bpo-30871: Add test.pythoninfo (bpo-3174) (bpo-3175)
    cce1cb9

    @vstinner
    Copy link
    Member Author

    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.

    @vstinner
    Copy link
    Member Author

    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

    @vstinner vstinner reopened this Aug 22, 2017
    @vstinner
    Copy link
    Member Author

    I created bpo-31260: [2.7] Enhance PC/VS9.0/ project to produce python.bat, as PCbuild/

    @vstinner
    Copy link
    Member Author

    I modified the buildbot configuration so a pythoninfo failure marks the build as WARNINGS instead of FAILED:
    python/buildmaster-config@3866fac

    But I'm not sure that it works :-/ I forced a build, but the build was marked as FAILED.

    @vstinner
    Copy link
    Member Author

    vstinner commented Sep 8, 2017

    pythoninfo is now available on all buildbots, including Python 2.7 VS9.0 buildbots:
    https://bugs.python.org/issue31260#msg301747

    @vstinner vstinner closed this as completed Sep 8, 2017
    @pablogsal
    Copy link
    Member

    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

    @pablogsal pablogsal reopened this Aug 12, 2018
    @pablogsal
    Copy link
    Member

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life tests Tests in the Lib/test dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    6 participants