Skip to content

Commit c0afb7f

Browse files
authored
bpo-39825: Fixes sysconfig.get_config_var('EXT_SUFFIX') on Windows to match distutils (GH-22088)
1 parent 0ef96c2 commit c0afb7f

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

Lib/sysconfig.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,11 @@ def _init_posix(vars):
424424
def _init_non_posix(vars):
425425
"""Initialize the module as appropriate for NT"""
426426
# set basic install directories
427+
import _imp
427428
vars['LIBDEST'] = get_path('stdlib')
428429
vars['BINLIBDEST'] = get_path('platstdlib')
429430
vars['INCLUDEPY'] = get_path('include')
430-
vars['EXT_SUFFIX'] = '.pyd'
431+
vars['EXT_SUFFIX'] = _imp.extension_suffixes()[0]
431432
vars['EXE'] = '.exe'
432433
vars['VERSION'] = _PY_VERSION_SHORT_NO_DOT
433434
vars['BINDIR'] = os.path.dirname(_safe_realpath(sys.executable))

Lib/test/test_sysconfig.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,12 @@ def test_SO_value(self):
360360

361361
@unittest.skipIf(sysconfig.get_config_var('EXT_SUFFIX') is None,
362362
'EXT_SUFFIX required for this test')
363-
def test_SO_in_vars(self):
363+
def test_EXT_SUFFIX_in_vars(self):
364+
import _imp
364365
vars = sysconfig.get_config_vars()
365366
self.assertIsNotNone(vars['SO'])
366367
self.assertEqual(vars['SO'], vars['EXT_SUFFIX'])
368+
self.assertEqual(vars['EXT_SUFFIX'], _imp.extension_suffixes()[0])
367369

368370
@unittest.skipUnless(sys.platform == 'linux' and
369371
hasattr(sys.implementation, '_multiarch'),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Windows: Change ``sysconfig.get_config_var('EXT_SUFFIX')`` to the expected
2+
full ``platform_tag.extension`` format. Previously it was hard-coded to
3+
``.pyd``, now it is compatible with ``distutils.sysconfig`` and will result
4+
in something like ``.cp38-win_amd64.pyd``. This brings windows into
5+
conformance with the other platforms.

0 commit comments

Comments
 (0)