-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
Set sys.abiflags
on Windows to make check free-threaded/debug builds easier
#127405
Comments
I'm not convinced this is non-impactful elsewhere. We would need to make sure that anywhere that uses something "defined" by The lack of documentation for experimental builds is somewhat deliberate right now. It's being documented outside of the main docs, as we don't want to confuse users with features that are not officially part of CPython. If you want more info about how to work with free-threaded builds, you'll have to find that (I don't remember where it is, but the discussion forums are a good place to start looking). |
Here is the search result of the following statements on GitHub:
Issue on the
The debug flag is included in the ABI tags. Here is the result that the Python is configured with $ python3 -c 'import sysconfig; print(sysconfig.get_config_var("EXT_SUFFIX"))'
.cpython-314td-darwin.so
A fresh installation built with $ python3 -VV
Python 3.14.0a2+ experimental free-threading build (heads/main:c46acd35888, Dec 3 2024, 01:17:32) [Clang 16.0.0 (clang-1600.0.26.4)]
$ python3 -c 'import sys; print(sys.abiflags)'
td
$ python3 -c 'import sysconfig; print(sysconfig.get_config_var("EXT_SUFFIX"))'
.cpython-314td-darwin.so |
Not on Windows - we use a
There are a number of differences like this between Windows and other platforms. It's really meaningless to test any of this on non-Windows and then assume it applies cross-platform, it really won't. (Also don't put too much faith in the docs. They're largely written by Linux developers for Linux developers, and only rarely branch out into other platforms.) |
There are no $ .\arm64\python3.14t_d.exe -c 'import pprint, sysconfig; pprint.pprint(sysconfig.get_config_vars())'
{'BINDIR': 'C:\\Users\\PanXuehai\\Projects\\cpython\\PCbuild\\arm64',
'BINLIBDEST': 'C:\\Users\\PanXuehai\\Projects\\cpython\\Lib',
'EXE': '.exe',
'EXT_SUFFIX': '_d.cp314t-win_arm64.pyd',
'INCLUDEPY': 'C:\\Users\\PanXuehai\\Projects\\cpython\\Include',
'LDLIBRARY': 'python314t_d.dll',
'implementation_lower': 'python',
'installed_base': 'C:\\Users\\PanXuehai\\Projects\\cpython',
'installed_platbase': 'C:\\Users\\PanXuehai\\Projects\\cpython',
'platbase': 'C:\\Users\\PanXuehai\\Projects\\cpython',
'platlibdir': 'DLLs',
'prefix': 'C:\\Users\\PanXuehai\\Projects\\cpython',
'projectbase': 'C:\\Users\\PanXuehai\\Projects\\cpython',
'py_version': '3.14.0a2+',
'py_version_nodot': '314',
'py_version_nodot_plat': '314t-arm64',
'py_version_short': '3.14',
'srcdir': 'C:\\Users\\PanXuehai\\Projects\\cpython',
'userbase': 'C:\\Users\\PanXuehai\\AppData\\Roaming\\Python'} I wonder if adding something that did not exist before would break historical things. cpython/Include/internal/pycore_importdl.h Lines 106 to 133 in 6cf7794
|
Yes, this is my concern, but I'm far more concerned about 3rd party code using This seems much like the discussion we had about using Being able to add |
For a concrete use-case, I'm trying to patch |
On Windows, it has been absent for all of that time. Changing from
Does |
For Python 3.8-3.12, it is true for normal builds. However, for Python 3.13, we have two different builds (the normal build and the free-threading build). It is inappropriate to assume the "absent" implies "empty string" in Python 3.13 and onwards. |
I'm talking about backwards compatibility, and how programs will change behaviour if we change our behaviour. As I've said a couple of times, that is my primary concern here. If you don't have any reason why it's safe, then let's deprecate Until then, use |
I'm curious what this would mean in practice. Is this just a note in the docs? |
Yeah, basically. The docs explicitly say it's only available on Unix, so it would get updated to indicate that it may be set on all platforms, and probably specify that a missing attribute is intended to be interpreted as an empty string. It may also need clarification that it isn't necessarily used the same on all platforms (it shouldn't be used to construct extension module suffixes, for example). In Porting Notes for the next two releases we'd say that Windows is going to start setting it to an empty string rather than being absent in 3.16. No reason to actually use the word "deprecation" except to explain what process we're following for changing a user-visible and documented API. |
Sounds reasonable to me. |
The first step is the doc update to rewrite the |
Feature or enhancement
Proposal:
Currently, the
sys.abiflags
attribute is only set on Unix systems. On Windows, there are nosys.abiflags
set (i.e.hasattr(sys, 'abiflags') -> False
). It is hard to tell if Python is in free-threaded or debug builds. Although developers can use something likesysconfig.get_config_var('Py_GIL_DISABLED')
. It is not well documented and is not convenient.cpython/Lib/test/test_sys.py
Lines 686 to 687 in 3afb639
cpython/Lib/test/test_sys.py
Lines 1294 to 1297 in 3afb639
It would be nice if we could set
ABIFLAGS
inpyconfig.h
and enablesys.abiflags
on Windows. This would simplify much code in the wild world and also in the CPython repo.Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
sys.abiflags
on Windows #127406The text was updated successfully, but these errors were encountered: