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 more details about the Python build in sys.version #100086
Comments
|
I don't think this change should be made. It potentially affects all users of Python, for example, the REPL users, but is of no benefit to 99% of them. All of this information is readily available via multiple other mechanisms, in particular, via
|
|
One motivation for me is that many users don't use Python binaries from python.org or from their Linux packaging system, but build their own binary with their custom recipe and it's not trivial to guess how the binary was built. Was it properly optimized with LTO+PGO? Was it built in debug mode? For a long time, the most popular Docker recipe to build Python used Today, I cannot recall if the macOS binary is optimized with LTO or not. Recently, @JulienPalard shared his recipe to build a custom Python with few lines of shell code: compile-python.sh. I was surprised to see
Well, these APIs are not great :-( test.pythoninfo is designed to be used on the command line, it doesn't have a simple API to query info about the current Python. sysconfig.get_config_vars() is hard to use: you have to guess which variable is the best to get compiler flags: make your choice in this long list, it can depend on how Python was built, in case of doubt you might have to check multiple variables. Moreover, once you have compiler options, you have to parse this string which is not trivial (I hate parsing shell). For LTO, do you have to check compiler flags or linker flags, hum? |
Ah? I'm not the 99%, I build Python on a daily basis and work on Python built in various ways. I know that :-) I saw this "debug build" vs "release build" as an useful information, but maybe it should be omitted for the common case: "release build" string? What about "lto+pgo": is it useful for most users? On my Fedora 37, sys.version is String length:
To make this string longer, the compiler part should be shorter: |
|
At the beginning, I started by modifying These lines don't say if Python was built in debug mode or not. The The first line is coming from the code: Since |
|
About the REPL, and The single line format ( |
|
I wrote PR #100093 which only changes the Python test runner (libregrtest), so it doesn't change the Python REPL nor |
The Python test runner (libregrtest) now logs Python build information like "debug" vs "release" build, or LTO and PGO optimizations.
|
Fixed by: 3c89202 |
vstinner commentedDec 7, 2022
•
edited by bedevere-bot
Currently, it's not easy to guess how Python was built just by looking at
python -VVoutput orsys.version.I propose to enhance
sys.versionto include more details about how Python was configured for the build:It should help me to more quickly identify if a buildbot was built in debug mode or release mode.
It should help to see how Python was optimized: with or without LTO and PGO optimizations?
It should help to quickly have an idea of which ABI is used: the "pystats" ABI is different than the "debug" than the "release" ABI.
Linked PRs
The text was updated successfully, but these errors were encountered: