1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
Description: distutils: Use python's compiler arguments by default
Get CONFIGURE_CFLAGS, CONFIGURE_CPPFLAGS, CONFIGURE_LDFLAGS from
the python build, when CFLAGS, CPPFLAGS, LDSHARED) are not set
in the environment.
Forwarded: no
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -211,9 +211,11 @@
_osx_support.customize_compiler(_config_vars)
_config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
- (cc, cxx, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \
+ (cc, cxx, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags,
+ configure_cppflags, configure_cflags, configure_ldflags) = \
get_config_vars('CC', 'CXX', 'CFLAGS',
- 'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
+ 'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS',
+ 'CONFIGURE_CPPFLAGS', 'CONFIGURE_CFLAGS', 'CONFIGURE_LDFLAGS')
if 'CC' in os.environ:
newcc = os.environ['CC']
@@ -234,13 +236,22 @@
cpp = cc + " -E" # not always
if 'LDFLAGS' in os.environ:
ldshared = ldshared + ' ' + os.environ['LDFLAGS']
+ elif configure_ldflags:
+ ldshared = ldshared + ' ' + configure_ldflags
if 'CFLAGS' in os.environ:
cflags = cflags + ' ' + os.environ['CFLAGS']
ldshared = ldshared + ' ' + os.environ['CFLAGS']
+ elif configure_cflags:
+ cflags = cflags + ' ' + configure_cflags
+ ldshared = ldshared + ' ' + configure_cflags
if 'CPPFLAGS' in os.environ:
cpp = cpp + ' ' + os.environ['CPPFLAGS']
cflags = cflags + ' ' + os.environ['CPPFLAGS']
ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
+ elif configure_cppflags:
+ cpp = cpp + ' ' + configure_cppflags
+ cflags = cflags + ' ' + configure_cppflags
+ ldshared = ldshared + ' ' + configure_cppflags
if 'AR' in os.environ:
ar = os.environ['AR']
if 'ARFLAGS' in os.environ:
@@ -254,7 +265,7 @@
compiler=cc_cmd,
compiler_so=cc_cmd + ' ' + ccshared,
compiler_cxx=cxx,
- linker_so=ldshared,
+ linker_so=ldshared + ' ' + ccshared,
linker_exe=cc,
archiver=archiver)
--- a/Lib/distutils/tests/test_sysconfig.py
+++ b/Lib/distutils/tests/test_sysconfig.py
@@ -162,18 +162,18 @@
comp = self.customize_compiler()
self.assertEqual(comp.exes['archiver'],
'sc_ar --sc-arflags')
- self.assertEqual(comp.exes['preprocessor'],
- 'sc_cc -E')
- self.assertEqual(comp.exes['compiler'],
- 'sc_cc --sc-cflags')
- self.assertEqual(comp.exes['compiler_so'],
- 'sc_cc --sc-cflags --sc-ccshared')
+ self.assertRegex(comp.exes['preprocessor'],
+ '^sc_cc -E.*')
+ self.assertRegex(comp.exes['compiler'],
+ '^sc_cc --sc-cflags.*')
+ self.assertRegex(comp.exes['compiler_so'],
+ '^sc_cc --sc-cflags .* --sc-ccshared')
self.assertEqual(comp.exes['compiler_cxx'],
'sc_cxx')
self.assertEqual(comp.exes['linker_exe'],
'sc_cc')
- self.assertEqual(comp.exes['linker_so'],
- 'sc_ldshared')
+ self.assertRegex(comp.exes['linker_so'],
+ 'sc_ldshared.*')
self.assertEqual(comp.shared_lib_extension, 'sc_shutil_suffix')
def test_parse_makefile_base(self):
|