diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-03-15 13:57:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-15 13:57:52 (GMT) |
commit | 86082c22d23285995a32aabb491527c9f5629556 (patch) | |
tree | 59b1cae8e4d09134670b5d3b50cc8a18c12a318c /Lib/distutils/tests | |
parent | 65f64b1903ae85b97a30f514bbc1b7ce940c3af2 (diff) | |
download | cpython-86082c22d23285995a32aabb491527c9f5629556.zip cpython-86082c22d23285995a32aabb491527c9f5629556.tar.gz cpython-86082c22d23285995a32aabb491527c9f5629556.tar.bz2 |
bpo-36235: Fix CFLAGS in distutils customize_compiler() (GH-12236)
Fix CFLAGS in customize_compiler() of distutils.sysconfig: when the
CFLAGS environment variable is defined, don't override CFLAGS variable with
the OPT variable anymore.
Initial patch written by David Malcolm.
Co-Authored-By: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'Lib/distutils/tests')
-rw-r--r-- | Lib/distutils/tests/test_sysconfig.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Lib/distutils/tests/test_sysconfig.py b/Lib/distutils/tests/test_sysconfig.py index fe4a299..4bf6a06 100644 --- a/Lib/distutils/tests/test_sysconfig.py +++ b/Lib/distutils/tests/test_sysconfig.py @@ -9,7 +9,7 @@ import unittest from distutils import sysconfig from distutils.ccompiler import get_default_compiler from distutils.tests import support -from test.support import TESTFN, run_unittest, check_warnings +from test.support import TESTFN, run_unittest, check_warnings, swap_item class SysconfigTestCase(support.EnvironGuard, unittest.TestCase): def setUp(self): @@ -78,7 +78,9 @@ class SysconfigTestCase(support.EnvironGuard, unittest.TestCase): 'not testing if default compiler is not unix') def test_customize_compiler(self): os.environ['AR'] = 'my_ar' - os.environ['ARFLAGS'] = '-arflags' + os.environ['CC'] = 'my_cc' + os.environ['ARFLAGS'] = '--myarflags' + os.environ['CFLAGS'] = '--mycflags' # make sure AR gets caught class compiler: @@ -87,9 +89,14 @@ class SysconfigTestCase(support.EnvironGuard, unittest.TestCase): def set_executables(self, **kw): self.exes = kw + # Make sure that sysconfig._config_vars is initialized + sysconfig.get_config_vars() + comp = compiler() - sysconfig.customize_compiler(comp) - self.assertEqual(comp.exes['archiver'], 'my_ar -arflags') + with swap_item(sysconfig._config_vars, 'CFLAGS', '--sysconfig-cflags'): + sysconfig.customize_compiler(comp) + self.assertEqual(comp.exes['archiver'], 'my_ar --myarflags') + self.assertEqual(comp.exes['compiler'], 'my_cc --sysconfig-cflags --mycflags') def test_parse_makefile_base(self): self.makefile = TESTFN |