]> granicus.if.org Git - python/commitdiff
Issue #13994: Earler partial revert of Distutils enhancements in 2.7
authorNed Deily <nad@acm.org>
Sat, 11 Feb 2012 19:40:24 +0000 (20:40 +0100)
committerNed Deily <nad@acm.org>
Sat, 11 Feb 2012 19:40:24 +0000 (20:40 +0100)
has left two versions of customize_compiler, the original in
distutils.sysconfig and another copy in distutils.ccompiler, with some
parts of distutils calling one and others using the other.
Complete the revert back to only having one in distutils.sysconfig as
is the case in 3.x.

Lib/distutils/ccompiler.py
Lib/distutils/command/build_clib.py
Lib/distutils/command/config.py
Lib/distutils/sysconfig.py
Lib/distutils/tests/test_build_clib.py
Lib/distutils/tests/test_ccompiler.py
Misc/NEWS

index c2b1f6fbe9d7226ad1bf58a20c21458cbd8ae791..7076b933946121d6a842dd8ec00c68d3117b858e 100644 (file)
@@ -18,58 +18,6 @@ from distutils.dep_util import newer_group
 from distutils.util import split_quoted, execute
 from distutils import log
 
-_sysconfig = __import__('sysconfig')
-
-def customize_compiler(compiler):
-    """Do any platform-specific customization of a CCompiler instance.
-
-    Mainly needed on Unix, so we can plug in the information that
-    varies across Unices and is stored in Python's Makefile.
-    """
-    if compiler.compiler_type == "unix":
-        (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \
-            _sysconfig.get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
-                                       'CCSHARED', 'LDSHARED', 'SO', 'AR',
-                                       'ARFLAGS')
-
-        if 'CC' in os.environ:
-            cc = os.environ['CC']
-        if 'CXX' in os.environ:
-            cxx = os.environ['CXX']
-        if 'LDSHARED' in os.environ:
-            ldshared = os.environ['LDSHARED']
-        if 'CPP' in os.environ:
-            cpp = os.environ['CPP']
-        else:
-            cpp = cc + " -E"           # not always
-        if 'LDFLAGS' in os.environ:
-            ldshared = ldshared + ' ' + os.environ['LDFLAGS']
-        if 'CFLAGS' in os.environ:
-            cflags = opt + ' ' + os.environ['CFLAGS']
-            ldshared = ldshared + ' ' + os.environ['CFLAGS']
-        if 'CPPFLAGS' in os.environ:
-            cpp = cpp + ' ' + os.environ['CPPFLAGS']
-            cflags = cflags + ' ' + os.environ['CPPFLAGS']
-            ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
-        if 'AR' in os.environ:
-            ar = os.environ['AR']
-        if 'ARFLAGS' in os.environ:
-            archiver = ar + ' ' + os.environ['ARFLAGS']
-        else:
-            archiver = ar + ' ' + ar_flags
-
-        cc_cmd = cc + ' ' + cflags
-        compiler.set_executables(
-            preprocessor=cpp,
-            compiler=cc_cmd,
-            compiler_so=cc_cmd + ' ' + ccshared,
-            compiler_cxx=cxx,
-            linker_so=ldshared,
-            linker_exe=cc,
-            archiver=archiver)
-
-        compiler.shared_lib_extension = so_ext
-
 class CCompiler:
     """Abstract base class to define the interface that must be implemented
     by real compiler classes.  Also has some utility methods used by
index 98a1726ffa8dd9d3e44b7fac3bd3c08e25ded734..205587e7fc96826da43641d748ed4a068928732c 100644 (file)
@@ -19,7 +19,7 @@ __revision__ = "$Id$"
 import os
 from distutils.core import Command
 from distutils.errors import DistutilsSetupError
-from distutils.ccompiler import customize_compiler
+from distutils.sysconfig import customize_compiler
 from distutils import log
 
 def show_compilers():
index da8da5953884f00ade3ab1915882214a3289a5f0..b084913563a3e234521a746be24b4fb2b4837c4a 100644 (file)
@@ -16,7 +16,7 @@ import re
 
 from distutils.core import Command
 from distutils.errors import DistutilsExecError
-from distutils.ccompiler import customize_compiler
+from distutils.sysconfig import customize_compiler
 from distutils import log
 
 LANG_EXT = {'c': '.c', 'c++': '.cxx'}
index 4f9041a794a5e94ec85eb610dfde88f1668ce5bd..4b193b2703c451c29fe2490c1cfb842cfa32830d 100644 (file)
@@ -150,9 +150,10 @@ 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, ar_flags) = \
             get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
-                            'CCSHARED', 'LDSHARED', 'SO')
+                            'CCSHARED', 'LDSHARED', 'SO', 'AR',
+                            'ARFLAGS')
 
         newcc = None
         if 'CC' in os.environ:
@@ -203,6 +204,12 @@ 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']
+        if 'ARFLAGS' in os.environ:
+            archiver = ar + ' ' + os.environ['ARFLAGS']
+        else:
+            archiver = ar + ' ' + ar_flags
 
         cc_cmd = cc + ' ' + cflags
         compiler.set_executables(
@@ -211,7 +218,8 @@ def customize_compiler(compiler):
             compiler_so=cc_cmd + ' ' + ccshared,
             compiler_cxx=cxx,
             linker_so=ldshared,
-            linker_exe=cc)
+            linker_exe=cc,
+            archiver=archiver)
 
         compiler.shared_lib_extension = so_ext
 
index 4f4e2bc7c6b8bfc08a0b2411c681fad63495f2c2..bef1bd99536e6a4bd945cbf11d15f552159129b0 100644 (file)
@@ -122,7 +122,8 @@ class BuildCLibTestCase(support.TempdirManager,
         # before we run the command, we want to make sure
         # all commands are present on the system
         # by creating a compiler and checking its executables
-        from distutils.ccompiler import new_compiler, customize_compiler
+        from distutils.ccompiler import new_compiler
+        from distutils.sysconfig import customize_compiler
 
         compiler = new_compiler()
         customize_compiler(compiler)
index e21873e821b3e4d2b7bf4b4697fdbd4c1e2157b5..45e477a429e669dc7ce85886274b76187e924514 100644 (file)
@@ -4,7 +4,8 @@ import unittest
 from test.test_support import captured_stdout
 
 from distutils.ccompiler import (gen_lib_options, CCompiler,
-                                 get_default_compiler, customize_compiler)
+                                 get_default_compiler)
+from distutils.sysconfig import customize_compiler
 from distutils import debug
 from distutils.tests import support
 
index 024a616878d89019d097b1972be72da04776daeb..15293b1b55931455340af57d70aadb0658714529 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -90,6 +90,13 @@ Core and Builtins
 Library
 -------
 
+- Issue #13994: Earler partial revert of Distutils enhancements in 2.7
+  has left two versions of customize_compiler, the original in
+  distutils.sysconfig and another copy in distutils.ccompiler, with some
+  parts of distutils calling one and others using the other.
+  Complete the revert back to only having one in distutils.sysconfig as
+  is the case in 3.x.
+
 - Issue #13590: On OS X 10.7 and 10.6 with Xcode 4.2, building
   Distutils-based packages with C extension modules may fail because
   Apple has removed gcc-4.2, the version used to build python.org