Merged revisions 73864 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r73864 | tarek.ziade | 2009-07-06 14:50:46 +0200 (Mon, 06 Jul 2009) | 1 line

  Fixed #6377: distutils compiler switch ignored (and added a deprecation warning if compiler is not used as supposed = a string option)
........
diff --git a/setup.py b/setup.py
index a6b09fe..c7e0a7e 100644
--- a/setup.py
+++ b/setup.py
@@ -174,7 +174,7 @@
         if compiler is not None:
             (ccshared,cflags) = sysconfig.get_config_vars('CCSHARED','CFLAGS')
             args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags
-        self.compiler.set_executables(**args)
+        self.compiler_obj.set_executables(**args)
 
         build_ext.build_extensions(self)
 
@@ -295,8 +295,8 @@
 
     def detect_modules(self):
         # Ensure that /usr/local is always used
-        add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
-        add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
+        add_dir_to_list(self.compiler_obj.library_dirs, '/usr/local/lib')
+        add_dir_to_list(self.compiler_obj.include_dirs, '/usr/local/include')
 
         # Add paths specified in the environment variables LDFLAGS and
         # CPPFLAGS for header and library files.
@@ -305,9 +305,9 @@
         # the environment variable is not set even though the value were passed
         # into configure and stored in the Makefile (issue found on OS X 10.3).
         for env_var, arg_name, dir_list in (
-                ('LDFLAGS', '-R', self.compiler.runtime_library_dirs),
-                ('LDFLAGS', '-L', self.compiler.library_dirs),
-                ('CPPFLAGS', '-I', self.compiler.include_dirs)):
+                ('LDFLAGS', '-R', self.compiler_obj.runtime_library_dirs),
+                ('LDFLAGS', '-L', self.compiler_obj.library_dirs),
+                ('CPPFLAGS', '-I', self.compiler_obj.include_dirs)):
             env_val = sysconfig.get_config_var(env_var)
             if env_val:
                 # To prevent optparse from raising an exception about any
@@ -333,19 +333,19 @@
                         add_dir_to_list(dir_list, directory)
 
         if os.path.normpath(sys.prefix) != '/usr':
-            add_dir_to_list(self.compiler.library_dirs,
+            add_dir_to_list(self.compiler_obj.library_dirs,
                             sysconfig.get_config_var("LIBDIR"))
-            add_dir_to_list(self.compiler.include_dirs,
+            add_dir_to_list(self.compiler_obj.include_dirs,
                             sysconfig.get_config_var("INCLUDEDIR"))
 
         # lib_dirs and inc_dirs are used to search for files;
         # if a file is found in one of those directories, it can
         # be assumed that no additional -I,-L directives are needed.
-        lib_dirs = self.compiler.library_dirs + [
+        lib_dirs = self.compiler_obj.library_dirs + [
             '/lib64', '/usr/lib64',
             '/lib', '/usr/lib',
             ]
-        inc_dirs = self.compiler.include_dirs + ['/usr/include']
+        inc_dirs = self.compiler_obj.include_dirs + ['/usr/include']
         exts = []
         missing = []
 
@@ -493,7 +493,7 @@
         exts.append( Extension('audioop', ['audioop.c']) )
 
         # readline
-        do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
+        do_readline = self.compiler_obj.find_library_file(lib_dirs, 'readline')
         if platform == 'darwin': # and os.uname()[2] < '9.':
             # MacOSX 10.4 has a broken readline. Don't try to build
             # the readline module unless the user has installed a fixed
@@ -514,17 +514,17 @@
                 readline_extra_link_args = ()
 
             readline_libs = ['readline']
-            if self.compiler.find_library_file(lib_dirs,
-                                                 'ncursesw'):
+            if self.compiler_obj.find_library_file(lib_dirs,
+                                                   'ncursesw'):
                 readline_libs.append('ncursesw')
-            elif self.compiler.find_library_file(lib_dirs,
-                                                 'ncurses'):
+            elif self.compiler_obj.find_library_file(lib_dirs,
+                                                     'ncurses'):
                 readline_libs.append('ncurses')
-            elif self.compiler.find_library_file(lib_dirs, 'curses'):
+            elif self.compiler_obj.find_library_file(lib_dirs, 'curses'):
                 readline_libs.append('curses')
-            elif self.compiler.find_library_file(lib_dirs +
-                                               ['/usr/lib/termcap'],
-                                               'termcap'):
+            elif self.compiler_obj.find_library_file(lib_dirs +
+                                                     ['/usr/lib/termcap'],
+                                                     'termcap'):
                 readline_libs.append('termcap')
             exts.append( Extension('readline', ['readline.c'],
                                    library_dirs=['/usr/lib/termcap'],
@@ -536,7 +536,7 @@
         if platform not in ['mac']:
             # crypt module.
 
-            if self.compiler.find_library_file(lib_dirs, 'crypt'):
+            if self.compiler_obj.find_library_file(lib_dirs, 'crypt'):
                 libs = ['crypt']
             else:
                 libs = []
@@ -563,7 +563,7 @@
                                ['/usr/kerberos/include'])
             if krb5_h:
                 ssl_incs += krb5_h
-        ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
+        ssl_libs = find_library_file(self.compiler_obj, 'ssl',lib_dirs,
                                      ['/usr/local/ssl/lib',
                                       '/usr/contrib/ssl/lib/'
                                      ] )
@@ -677,7 +677,7 @@
                 os.path.join(sqlite_incdir, '..', '..', 'lib64'),
                 os.path.join(sqlite_incdir, '..', '..', 'lib'),
             ]
-            sqlite_libfile = self.compiler.find_library_file(
+            sqlite_libfile = self.compiler_obj.find_library_file(
                                 sqlite_dirs_to_check + lib_dirs, 'sqlite3')
             if sqlite_libfile:
                 sqlite_libdir = [os.path.abspath(os.path.dirname(sqlite_libfile))]
@@ -736,7 +736,8 @@
                 if cand == "ndbm":
                     if find_file("ndbm.h", inc_dirs, []) is not None:
                         # Some systems have -lndbm, others don't
-                        if self.compiler.find_library_file(lib_dirs, 'ndbm'):
+                        if self.compiler_obj.find_library_file(lib_dirs,
+                                                               'ndbm'):
                             ndbm_libs = ['ndbm']
                         else:
                             ndbm_libs = []
@@ -749,9 +750,10 @@
                         break
 
                 elif cand == "gdbm":
-                    if self.compiler.find_library_file(lib_dirs, 'gdbm'):
+                    if self.compiler_obj.find_library_file(lib_dirs, 'gdbm'):
                         gdbm_libs = ['gdbm']
-                        if self.compiler.find_library_file(lib_dirs, 'gdbm_compat'):
+                        if self.compiler_obj.find_library_file(lib_dirs,
+                                                               'gdbm_compat'):
                             gdbm_libs.append('gdbm_compat')
                         if find_file("gdbm/ndbm.h", inc_dirs, []) is not None:
                             print("building dbm using gdbm")
@@ -778,7 +780,7 @@
                 missing.append('_dbm')
 
         # Anthony Baxter's gdbm module.  GNU dbm(3) will require -lgdbm:
-        if (self.compiler.find_library_file(lib_dirs, 'gdbm')):
+        if (self.compiler_obj.find_library_file(lib_dirs, 'gdbm')):
             exts.append( Extension('_gdbm', ['_gdbmmodule.c'],
                                    libraries = ['gdbm'] ) )
         else:
@@ -796,7 +798,7 @@
 
             # Sun yellow pages. Some systems have the functions in libc.
             if platform not in ['cygwin', 'atheos', 'qnx6']:
-                if (self.compiler.find_library_file(lib_dirs, 'nsl')):
+                if (self.compiler_obj.find_library_file(lib_dirs, 'nsl')):
                     libs = ['nsl']
                 else:
                     libs = []
@@ -810,24 +812,24 @@
         # Curses support, requiring the System V version of curses, often
         # provided by the ncurses library.
         panel_library = 'panel'
-        if (self.compiler.find_library_file(lib_dirs, 'ncursesw')):
+        if (self.compiler_obj.find_library_file(lib_dirs, 'ncursesw')):
             curses_libs = ['ncursesw']
             # Bug 1464056: If _curses.so links with ncursesw,
             # _curses_panel.so must link with panelw.
             panel_library = 'panelw'
             exts.append( Extension('_curses', ['_cursesmodule.c'],
                                    libraries = curses_libs) )
-        elif (self.compiler.find_library_file(lib_dirs, 'ncurses')):
+        elif (self.compiler_obj.find_library_file(lib_dirs, 'ncurses')):
             curses_libs = ['ncurses']
             exts.append( Extension('_curses', ['_cursesmodule.c'],
                                    libraries = curses_libs) )
-        elif (self.compiler.find_library_file(lib_dirs, 'curses')
+        elif (self.compiler_obj.find_library_file(lib_dirs, 'curses')
               and platform != 'darwin'):
                 # OSX has an old Berkeley curses, not good enough for
                 # the _curses module.
-            if (self.compiler.find_library_file(lib_dirs, 'terminfo')):
+            if (self.compiler_obj.find_library_file(lib_dirs, 'terminfo')):
                 curses_libs = ['curses', 'terminfo']
-            elif (self.compiler.find_library_file(lib_dirs, 'termcap')):
+            elif (self.compiler_obj.find_library_file(lib_dirs, 'termcap')):
                 curses_libs = ['curses', 'termcap']
             else:
                 curses_libs = ['curses']
@@ -839,7 +841,7 @@
 
         # If the curses module is enabled, check for the panel module
         if (module_enabled(exts, '_curses') and
-            self.compiler.find_library_file(lib_dirs, panel_library)):
+            self.compiler_obj.find_library_file(lib_dirs, panel_library)):
             exts.append( Extension('_curses_panel', ['_curses_panel.c'],
                                    libraries = [panel_library] + curses_libs) )
         else:
@@ -872,7 +874,7 @@
                     version = line.split()[2]
                     break
             if version >= version_req:
-                if (self.compiler.find_library_file(lib_dirs, 'z')):
+                if (self.compiler_obj.find_library_file(lib_dirs, 'z')):
                     if sys.platform == "darwin":
                         zlib_extra_link_args = ('-Wl,-search_paths_first',)
                     else:
@@ -904,7 +906,7 @@
                                extra_link_args = extra_link_args) )
 
         # Gustavo Niemeyer's bz2 module.
-        if (self.compiler.find_library_file(lib_dirs, 'bz2')):
+        if (self.compiler_obj.find_library_file(lib_dirs, 'bz2')):
             if sys.platform == "darwin":
                 bz2_extra_link_args = ('-Wl,-search_paths_first',)
             else:
@@ -1130,8 +1132,10 @@
         tcllib = tklib = tcl_includes = tk_includes = None
         for version in ['8.5', '85', '8.4', '84', '8.3', '83', '8.2',
                         '82', '8.1', '81', '8.0', '80']:
-            tklib = self.compiler.find_library_file(lib_dirs, 'tk' + version)
-            tcllib = self.compiler.find_library_file(lib_dirs, 'tcl' + version)
+            tklib = self.compiler_obj.find_library_file(lib_dirs,
+                                                        'tk' + version)
+            tcllib = self.compiler_obj.find_library_file(lib_dirs,
+                                                         'tcl' + version)
             if tklib and tcllib:
                 # Exit the loop when we've found the Tcl/Tk libraries
                 break
@@ -1189,12 +1193,12 @@
                 return
 
         # Check for BLT extension
-        if self.compiler.find_library_file(lib_dirs + added_lib_dirs,
-                                           'BLT8.0'):
+        if self.compiler_obj.find_library_file(lib_dirs + added_lib_dirs,
+                                               'BLT8.0'):
             defs.append( ('WITH_BLT', 1) )
             libs.append('BLT8.0')
-        elif self.compiler.find_library_file(lib_dirs + added_lib_dirs,
-                                           'BLT'):
+        elif self.compiler_obj.find_library_file(lib_dirs + added_lib_dirs,
+                                                'BLT'):
             defs.append( ('WITH_BLT', 1) )
             libs.append('BLT')
 
@@ -1248,7 +1252,7 @@
                              ]]
 
         # Add .S (preprocessed assembly) to C compiler source extensions.
-        self.compiler.src_extensions.append('.S')
+        self.compiler_obj.src_extensions.append('.S')
 
         include_dirs = [os.path.join(ffi_srcdir, 'include'),
                         os.path.join(ffi_srcdir, 'powerpc')]
@@ -1298,7 +1302,7 @@
             ffi_srcdir = os.path.join(fficonfig['ffi_srcdir'], 'src')
 
             # Add .S (preprocessed assembly) to C compiler source extensions.
-            self.compiler.src_extensions.append('.S')
+            self.compiler_obj.src_extensions.append('.S')
 
             include_dirs = [os.path.join(ffi_builddir, 'include'),
                             ffi_builddir, ffi_srcdir]
@@ -1376,7 +1380,7 @@
         ffi_lib = None
         if ffi_inc is not None:
             for lib_name in ('ffi_convenience', 'ffi_pic', 'ffi'):
-                if (self.compiler.find_library_file(lib_dirs, lib_name)):
+                if (self.compiler_obj.find_library_file(lib_dirs, lib_name)):
                     ffi_lib = lib_name
                     break