[Python-checkins] cpython (2.7): Issue #13994: Earler partial revert of Distutils enhancements in 2.7

ned.deily python-checkins at python.org
Sat Feb 11 20:42:37 CET 2012


http://hg.python.org/cpython/rev/6240ff5dfebe
changeset:   74871:6240ff5dfebe
branch:      2.7
parent:      74866:adf555991f8b
user:        Ned Deily <nad at acm.org>
date:        Sat Feb 11 20:40:24 2012 +0100
summary:
  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.

files:
  Lib/distutils/ccompiler.py             |  52 --------------
  Lib/distutils/command/build_clib.py    |   2 +-
  Lib/distutils/command/config.py        |   2 +-
  Lib/distutils/sysconfig.py             |  14 ++-
  Lib/distutils/tests/test_build_clib.py |   3 +-
  Lib/distutils/tests/test_ccompiler.py  |   3 +-
  Misc/NEWS                              |   7 +
  7 files changed, 24 insertions(+), 59 deletions(-)


diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py
--- a/Lib/distutils/ccompiler.py
+++ b/Lib/distutils/ccompiler.py
@@ -18,58 +18,6 @@
 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
diff --git a/Lib/distutils/command/build_clib.py b/Lib/distutils/command/build_clib.py
--- a/Lib/distutils/command/build_clib.py
+++ b/Lib/distutils/command/build_clib.py
@@ -19,7 +19,7 @@
 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():
diff --git a/Lib/distutils/command/config.py b/Lib/distutils/command/config.py
--- a/Lib/distutils/command/config.py
+++ b/Lib/distutils/command/config.py
@@ -16,7 +16,7 @@
 
 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'}
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -150,9 +150,10 @@
     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 @@
             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 @@
             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
 
diff --git a/Lib/distutils/tests/test_build_clib.py b/Lib/distutils/tests/test_build_clib.py
--- a/Lib/distutils/tests/test_build_clib.py
+++ b/Lib/distutils/tests/test_build_clib.py
@@ -122,7 +122,8 @@
         # 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)
diff --git a/Lib/distutils/tests/test_ccompiler.py b/Lib/distutils/tests/test_ccompiler.py
--- a/Lib/distutils/tests/test_ccompiler.py
+++ b/Lib/distutils/tests/test_ccompiler.py
@@ -4,7 +4,8 @@
 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
 
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -90,6 +90,13 @@
 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

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list