Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9121f8d

Browse files
committed
Issue 19555 for distutils, plus a little clean up (pyflakes, line lengths).
1 parent aa40775 commit 9121f8d

3 files changed

Lines changed: 45 additions & 15 deletions

File tree

Lib/distutils/sysconfig.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,11 @@ def get_config_vars(*args):
518518
_config_vars['prefix'] = PREFIX
519519
_config_vars['exec_prefix'] = EXEC_PREFIX
520520

521+
# For backward compatibility, see issue19555
522+
SO = _config_vars.get('EXT_SUFFIX')
523+
if SO is not None:
524+
_config_vars['SO'] = SO
525+
521526
# Always convert srcdir to an absolute path
522527
srcdir = _config_vars.get('srcdir', project_base)
523528
if os.name == 'posix':
@@ -568,4 +573,7 @@ def get_config_var(name):
568573
returned by 'get_config_vars()'. Equivalent to
569574
get_config_vars().get(name)
570575
"""
576+
if name == 'SO':
577+
import warnings
578+
warnings.warn('SO is deprecated, use EXT_SUFFIX', DeprecationWarning)
571579
return get_config_vars().get(name)

Lib/distutils/tests/test_sysconfig.py

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
"""Tests for distutils.sysconfig."""
22
import os
33
import shutil
4-
import test
54
import unittest
65

76
from distutils import sysconfig
87
from distutils.ccompiler import get_default_compiler
98
from distutils.tests import support
109
from test.support import TESTFN, run_unittest
1110

12-
class SysconfigTestCase(support.EnvironGuard,
13-
unittest.TestCase):
11+
class SysconfigTestCase(support.EnvironGuard, unittest.TestCase):
1412
def setUp(self):
1513
super(SysconfigTestCase, self).setUp()
1614
self.makefile = None
@@ -32,7 +30,6 @@ def test_get_config_h_filename(self):
3230
self.assertTrue(os.path.isfile(config_h), config_h)
3331

3432
def test_get_python_lib(self):
35-
lib_dir = sysconfig.get_python_lib()
3633
# XXX doesn't work on Linux when Python was never installed before
3734
#self.assertTrue(os.path.isdir(lib_dir), lib_dir)
3835
# test for pythonxx.lib?
@@ -67,8 +64,9 @@ def test_srcdir(self):
6764
self.assertTrue(os.path.exists(Python_h), Python_h)
6865
self.assertTrue(sysconfig._is_python_source_dir(srcdir))
6966
elif os.name == 'posix':
70-
self.assertEqual(os.path.dirname(sysconfig.get_makefile_filename()),
71-
srcdir)
67+
self.assertEqual(
68+
os.path.dirname(sysconfig.get_makefile_filename()),
69+
srcdir)
7270

7371
def test_srcdir_independent_of_cwd(self):
7472
# srcdir should be independent of the current working directory
@@ -129,10 +127,13 @@ def test_parse_makefile_literal_dollar(self):
129127

130128
def test_sysconfig_module(self):
131129
import sysconfig as global_sysconfig
132-
self.assertEqual(global_sysconfig.get_config_var('CFLAGS'), sysconfig.get_config_var('CFLAGS'))
133-
self.assertEqual(global_sysconfig.get_config_var('LDFLAGS'), sysconfig.get_config_var('LDFLAGS'))
130+
self.assertEqual(global_sysconfig.get_config_var('CFLAGS'),
131+
sysconfig.get_config_var('CFLAGS'))
132+
self.assertEqual(global_sysconfig.get_config_var('LDFLAGS'),
133+
sysconfig.get_config_var('LDFLAGS'))
134134

135-
@unittest.skipIf(sysconfig.get_config_var('CUSTOMIZED_OSX_COMPILER'),'compiler flags customized')
135+
@unittest.skipIf(sysconfig.get_config_var('CUSTOMIZED_OSX_COMPILER'),
136+
'compiler flags customized')
136137
def test_sysconfig_compiler_vars(self):
137138
# On OS X, binary installers support extension module building on
138139
# various levels of the operating system with differing Xcode
@@ -151,9 +152,29 @@ def test_sysconfig_compiler_vars(self):
151152
import sysconfig as global_sysconfig
152153
if sysconfig.get_config_var('CUSTOMIZED_OSX_COMPILER'):
153154
return
154-
self.assertEqual(global_sysconfig.get_config_var('LDSHARED'), sysconfig.get_config_var('LDSHARED'))
155-
self.assertEqual(global_sysconfig.get_config_var('CC'), sysconfig.get_config_var('CC'))
156-
155+
self.assertEqual(global_sysconfig.get_config_var('LDSHARED'),
156+
sysconfig.get_config_var('LDSHARED'))
157+
self.assertEqual(global_sysconfig.get_config_var('CC'),
158+
sysconfig.get_config_var('CC'))
159+
160+
@unittest.skipIf(sysconfig.get_config_var('EXT_SUFFIX') is None,
161+
'EXT_SUFFIX required for this test')
162+
def test_SO_deprecation(self):
163+
self.assertWarns(DeprecationWarning,
164+
sysconfig.get_config_var, 'SO')
165+
166+
@unittest.skipIf(sysconfig.get_config_var('EXT_SUFFIX') is None,
167+
'EXT_SUFFIX required for this test')
168+
def test_SO_value(self):
169+
self.assertEqual(sysconfig.get_config_var('SO'),
170+
sysconfig.get_config_var('EXT_SUFFIX'))
171+
172+
@unittest.skipIf(sysconfig.get_config_var('EXT_SUFFIX') is None,
173+
'EXT_SUFFIX required for this test')
174+
def test_SO_in_vars(self):
175+
vars = sysconfig.get_config_vars()
176+
self.assertIsNotNone(vars['SO'])
177+
self.assertEqual(vars['SO'], vars['EXT_SUFFIX'])
157178

158179

159180
def test_suite():

Misc/NEWS

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ Projected release date: 2013-11-24
1010
Core and Builtins
1111
-----------------
1212

13-
- Use the repr of a module name in more places in import, especially exceptions.
13+
- Use the repr of a module name in more places in import, especially
14+
exceptions.
1415

1516
- Issue #19619: str.encode, bytes.decode and bytearray.decode now use an
1617
internal API to throw LookupError for known non-text encodings, rather
@@ -79,8 +80,8 @@ Library
7980
CRL enumeration are now two functions. enum_certificates() also returns
8081
purpose flags as set of OIDs.
8182

82-
- Issue #19555: Restore sysconfig.get_config_var('SO'), with a
83-
DeprecationWarning pointing people at $EXT_SUFFIX.
83+
- Issue #19555: Restore sysconfig.get_config_var('SO'), (and the distutils
84+
equivalent) with a DeprecationWarning pointing people at $EXT_SUFFIX.
8485

8586
- Issue #8813: Add SSLContext.verify_flags to change the verification flags
8687
of the context in order to enable certification revocation list (CRL)

0 commit comments

Comments
 (0)