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

gh-127405: Add ABIFLAGS to sysconfig.get_config_vars() on Windows #131799

Merged
merged 58 commits into from
Apr 11, 2025

Conversation

XuehaiPan
Copy link
Contributor

@XuehaiPan XuehaiPan commented Mar 27, 2025

Set an upper-cased ABIFLAGS (previously not exist) to sysconfig.get_config_vars() on Windows.
The lower-cased abiflags in sysconfig.get_config_vars() remains an empty string on Windows.

See #127405 (comment).

@XuehaiPan XuehaiPan requested a review from zooba March 28, 2025 11:03
Comment on lines 58 to 74

// On Unix, the `ABIFLAGS` key is defined via a different logic.
//
// Emulate `sys.abiflags` value on Unix for Windows. ABIFLAGS here is only
// an emulated value. It is not present during build on Windows.
if (add_string_value(config, "ABIFLAGS",
# ifdef Py_GIL_DISABLED
"t"
# endif
# ifdef _DEBUG
"d"
# endif
"")
< 0) {
Py_DECREF(config);
return NULL;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of setting ABIFLAGS here, I'd prefer to add Py_DEBUG and then construct ABIFLAGS in sysconfig._init_non_posix.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with adding Py_DEBUG, but if anything we should construct ABIFLAGS further back in the build (e.g. in a .props file) and store that value here.

We don't need or use it, though, so I don't see an issue with constructing it here. But I'd rather have build variables be closer to the build rather than further away.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, Py_DEBUG and Py_GIL_DISABLED should be in pyconfig.h, removing the need for a native module in the first place.

But ignoring that, I think it would be more maintainable to have all variables that need construction in the same place. Having part of them here, and part of them in the Python module should be avoidable if we can.

Especially for Windows specific variables emulating POSIX ones, sysconfig._init_non_posix is the place I would expect them to be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have a strong preference for whether the code should live in Python or C. Both are fine for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have a strong preference for whether the code should live in Python or C. Both are fine for me.

I move the definition from C to Python in the latest commit. I can either keep it or revert it if we reach a consensus.

@XuehaiPan XuehaiPan requested review from zooba and merwok April 8, 2025 16:58
Copy link
Member

@merwok merwok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM – waiting for Steve’s approval

Copy link
Member

@zooba zooba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nearly there! I just want to see that unspecified test clarified/removed, and we'll run it across all the platforms just to make sure the other test change is valid for them all.

def test_abi_debug(self):
ABIFLAGS = sysconfig.get_config_var('ABIFLAGS')
if support.Py_DEBUG:
# The 'd' flag should always be the last one.
Copy link
Member

@zooba zooba Apr 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't know if it's guaranteed.

Show me the definition of ABIFLAGS that specifies it (trick question - no such definition exists).

Let's not invent a specification in a barely-related PR. Make this a Windows-specific test that checks for _d at the end (or just check 'd' in ABIFLAGS), but don't touch other platforms.

@XuehaiPan XuehaiPan requested a review from zooba April 11, 2025 11:21
@zooba zooba added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Apr 11, 2025
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @zooba for commit d55b3e6 🤖

Results will be shown at:

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

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

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Apr 11, 2025
@zooba
Copy link
Member

zooba commented Apr 11, 2025

Looks like the buildbots were fine apart from the darwin ones, which has been fixed. So I'll merge it and we should keep an eye on any more failures (though I'm about to be AFK for the weekend and won't actually be watching... will look on Monday!)

@zooba zooba merged commit 26ae05e into python:main Apr 11, 2025
42 checks passed
@zooba
Copy link
Member

zooba commented Apr 11, 2025

Thanks for the contribution! And for bearing with me to make sure we get it right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants