]> granicus.if.org Git - python/commitdiff
fixed #1520877: now distutils reads Read from the environment/Makefile
authorTarek Ziadé <ziade.tarek@gmail.com>
Fri, 6 Feb 2009 01:15:51 +0000 (01:15 +0000)
committerTarek Ziadé <ziade.tarek@gmail.com>
Fri, 6 Feb 2009 01:15:51 +0000 (01:15 +0000)
Lib/distutils/sysconfig.py
Lib/distutils/tests/test_sysconfig.py
Misc/NEWS

index ec2f8a9c334bce1cc29cdb3b9840db6ca56fda1b..deb51a1c1a1c84690355078ca39b39184fee7ad3 100644 (file)
@@ -165,9 +165,9 @@ def customize_compiler(compiler):
     varies across Unices and is stored in Python's Makefile.
     """
     if compiler.compiler_type == "unix":
-        (cc, cxx, opt, cflags, ccshared, ldshared, so_ext) = \
+        (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar) = \
             get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
-                            'CCSHARED', 'LDSHARED', 'SO')
+                            'CCSHARED', 'LDSHARED', 'SO', 'AR')
 
         if 'CC' in os.environ:
             cc = os.environ['CC']
@@ -188,6 +188,8 @@ def customize_compiler(compiler):
             cpp = cpp + ' ' + os.environ['CPPFLAGS']
             cflags = cflags + ' ' + os.environ['CPPFLAGS']
             ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
+        if 'AR' in os.environ:
+            ar = os.environ['AR']
 
         cc_cmd = cc + ' ' + cflags
         compiler.set_executables(
@@ -196,7 +198,8 @@ def customize_compiler(compiler):
             compiler_so=cc_cmd + ' ' + ccshared,
             compiler_cxx=cxx,
             linker_so=ldshared,
-            linker_exe=cc)
+            linker_exe=cc,
+            archiver=ar)
 
         compiler.shared_lib_extension = so_ext
 
index 397bb12cfce5d429040fd30cc1968c00bcbed621..7f0bce63c9f9227501e65c88cb46be954d3ba0f9 100644 (file)
@@ -8,6 +8,13 @@ from test.test_support import TESTFN
 
 class SysconfigTestCase(unittest.TestCase):
 
+    def setUp(self):
+        self.old_AR = os.environ.get('AR')
+
+    def tearDown(self):
+        if self.old_AR is not None:
+            os.environ['AR'] = self.old_AR
+
     def test_get_config_h_filename(self):
         config_h = sysconfig.get_config_h_filename()
         self.assert_(os.path.isfile(config_h), config_h)
@@ -32,6 +39,21 @@ class SysconfigTestCase(unittest.TestCase):
         self.assert_(isinstance(cvars, dict))
         self.assert_(cvars)
 
+    def test_customize_compiler(self):
+
+        os.environ['AR'] = 'xxx'
+
+        # make sure AR gets caught
+        class compiler:
+            compiler_type = 'unix'
+
+            def set_executables(self, **kw):
+                self.exes = kw
+
+        comp = compiler()
+        sysconfig.customize_compiler(comp)
+        self.assertEquals(comp.exes['archiver'], 'xxx')
+
 
 def test_suite():
     suite = unittest.TestSuite()
index 6ec126930b8ee3a8b31bc9cf47c467620967191f..c84325796ee76f32fbc581d5727915c0b633f765 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -149,6 +149,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #1520877: Now distutils.sysconfig reads $AR from the 
+  environment/Makefile. Patch by Douglas Greiman.
+
 - Issue #4285: Change sys.version_info to be a named tuple. Patch by
   Ross Light.