-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-127405: Add ABIFLAGS
to sysconfig.get_config_vars()
on Windows
#131799
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
Changes from 53 commits
31b7eab
dc45897
9a4586a
76c85bb
b98419b
4729f76
04cbb1c
a6045ea
584e0b0
93257be
30c7b56
97942b2
917874c
f49067e
8fa952b
08d92db
b667dd9
30cf6c7
5df9540
018aae3
4f22ff3
f918241
a4646c5
7b21d7d
1ee8230
084deac
af50632
b397f40
1a82cd1
7990798
0744690
518137b
486e2a8
3bccf1d
780f340
98c26f9
e236bc7
0d8bcdd
278556c
5689c1f
299cec6
21d2e73
d265a59
f3b8570
fe4ea95
da2b4ce
64f0961
8b16454
1c807f0
fbb86f5
b702ff9
932386c
23b6e6c
75b6c51
3c91201
d55b3e6
a084070
d2255e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
import textwrap | ||
from copy import copy | ||
|
||
from test import support | ||
from test.support import ( | ||
captured_stdout, | ||
is_android, | ||
|
@@ -455,20 +456,19 @@ def test_library(self): | |
library = sysconfig.get_config_var('LIBRARY') | ||
ldlibrary = sysconfig.get_config_var('LDLIBRARY') | ||
major, minor = sys.version_info[:2] | ||
if sys.platform == 'win32': | ||
self.assertTrue(library.startswith(f'python{major}{minor}')) | ||
self.assertTrue(library.endswith('.dll')) | ||
abiflags = sysconfig.get_config_var('ABIFLAGS') | ||
if sys.platform.startswith('win'): | ||
self.assertEqual(library, f'python{major}{minor}{abiflags}.dll') | ||
self.assertEqual(library, ldlibrary) | ||
elif is_apple_mobile: | ||
framework = sysconfig.get_config_var('PYTHONFRAMEWORK') | ||
self.assertEqual(ldlibrary, f"{framework}.framework/{framework}") | ||
else: | ||
self.assertTrue(library.startswith(f'libpython{major}.{minor}')) | ||
self.assertTrue(library.endswith('.a')) | ||
self.assertEqual(library, f'libpython{major}.{minor}{abiflags}.a') | ||
XuehaiPan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if sys.platform == 'darwin' and sys._framework: | ||
self.skipTest('gh-110824: skip LDLIBRARY test for framework build') | ||
else: | ||
self.assertTrue(ldlibrary.startswith(f'libpython{major}.{minor}')) | ||
self.assertStartsWith(ldlibrary, f'libpython{major}.{minor}{abiflags}') | ||
|
||
@unittest.skipUnless(sys.platform == "darwin", "test only relevant on MacOSX") | ||
@requires_subprocess() | ||
|
@@ -592,6 +592,60 @@ def test_osx_ext_suffix(self): | |
suffix = sysconfig.get_config_var('EXT_SUFFIX') | ||
self.assertTrue(suffix.endswith('-darwin.so'), suffix) | ||
|
||
def test_always_set_py_debug(self): | ||
self.assertIn('Py_DEBUG', sysconfig.get_config_vars()) | ||
Py_DEBUG = sysconfig.get_config_var('Py_DEBUG') | ||
self.assertIn(Py_DEBUG, (0, 1)) | ||
self.assertEqual(Py_DEBUG, support.Py_DEBUG) | ||
|
||
def test_always_set_py_gil_disabled(self): | ||
self.assertIn('Py_GIL_DISABLED', sysconfig.get_config_vars()) | ||
Py_GIL_DISABLED = sysconfig.get_config_var('Py_GIL_DISABLED') | ||
self.assertIn(Py_GIL_DISABLED, (0, 1)) | ||
self.assertEqual(Py_GIL_DISABLED, support.Py_GIL_DISABLED) | ||
|
||
def test_abiflags(self): | ||
XuehaiPan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# If this test fails on some platforms, maintainers should update the | ||
# test to make it pass, rather than changing the definition of ABIFLAGS. | ||
self.assertIn('abiflags', sysconfig.get_config_vars()) | ||
self.assertIn('ABIFLAGS', sysconfig.get_config_vars()) | ||
< A3E2 span class='blob-code-inner blob-code-marker ' data-code-marker="+"> abiflags = sysconfig.get_config_var('abiflags') | ||
ABIFLAGS = sysconfig.get_config_var('ABIFLAGS') | ||
self.assertIsInstance(abiflags, str) | ||
self.assertIsInstance(ABIFLAGS, str) | ||
self.assertIn(abiflags, ABIFLAGS) | ||
if os.name == 'nt': | ||
self.assertEqual(abiflags, '') | ||
|
||
if not sys.platform.startswith('win'): | ||
valid_abiflags = ('', 't', 'd', 'td') | ||
else: | ||
# Windows uses '_d' rather than 'd'; see also test_abi_debug below | ||
valid_abiflags = ('', 't', '_d', 't_d') | ||
|
||
self.assertIn(ABIFLAGS, valid_abiflags) | ||
|
||
def test_abi_debug(self): | ||
ABIFLAGS = sysconfig.get_config_var('ABIFLAGS') | ||
if support.Py_DEBUG: | ||
# The 'd' flag should always be the last one. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if this is guaranteed. Yes, we require it for Windows, but it may not be so for all platforms. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This condition has been held since Python 3.8 to today (3.14dev). There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Let's not invent a specification in a barely-related PR. Make this a Windows-specific test that checks for |
||
# On Windows, the debug flag is used differently with a underscore prefix. | ||
# For example, `python{X}.{Y}td` on Unix and `python{X}.{Y}t_d.exe` on Windows. | ||
self.assertEndsWith(ABIFLAGS, 'd') | ||
else: | ||
self.assertNotIn('d', ABIFLAGS) | ||
|
||
def test_abi_thread(self): | ||
abi_thread = sysconfig.get_config_var('abi_thread') | ||
ABIFLAGS = sysconfig.get_config_var('ABIFLAGS') | ||
self.assertIsInstance(abi_thread, str) | ||
if support.Py_GIL_DISABLED: | ||
self.assertEqual(abi_thread, 't') | ||
self.assertIn('t', ABIFLAGS) | ||
else: | ||
self.assertEqual(abi_thread, '') | ||
self.assertNotIn('t', ABIFLAGS) | ||
|
||
@requires_subprocess() | ||
def test_makefile_overwrites_config_vars(self): | ||
script = textwrap.dedent(""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add ``ABIFLAGS`` to :func:`sysconfig.get_config_vars` on Windows. Patch by Xuehai Pan. |
Uh oh!
There was an error while loading. Please reload this page.