[Python-checkins] r72446 - in python/branches/py3k: Lib/distutils/sysconfig.py Lib/distutils/tests/test_build_clib.py Lib/distutils/tests/test_sysconfig.py Makefile.pre.in Misc/ACKS Misc/NEWS configure.in

tarek.ziade python-checkins at python.org
Thu May 7 23:24:44 CEST 2009


Author: tarek.ziade
Date: Thu May  7 23:24:43 2009
New Revision: 72446

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

........
  r72445 | tarek.ziade | 2009-05-07 23:20:34 +0200 (Thu, 07 May 2009) | 1 line
  
  Fixed #5941: added ARFLAGS for the archiver command.
........


Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Lib/distutils/sysconfig.py
   python/branches/py3k/Lib/distutils/tests/test_build_clib.py
   python/branches/py3k/Lib/distutils/tests/test_sysconfig.py
   python/branches/py3k/Makefile.pre.in
   python/branches/py3k/Misc/ACKS
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/configure.in

Modified: python/branches/py3k/Lib/distutils/sysconfig.py
==============================================================================
--- python/branches/py3k/Lib/distutils/sysconfig.py	(original)
+++ python/branches/py3k/Lib/distutils/sysconfig.py	Thu May  7 23:24:43 2009
@@ -160,9 +160,9 @@
     varies across Unices and is stored in Python's Makefile.
     """
     if compiler.compiler_type == "unix":
-        (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar) = \
+        (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \
             get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
-                            'CCSHARED', 'LDSHARED', 'SO', 'AR')
+                            'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS')
 
         if 'CC' in os.environ:
             cc = os.environ['CC']
@@ -185,6 +185,10 @@
             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(
@@ -194,7 +198,7 @@
             compiler_cxx=cxx,
             linker_so=ldshared,
             linker_exe=cc,
-            archiver=ar)
+            archiver=archiver)
 
         compiler.shared_lib_extension = so_ext
 

Modified: python/branches/py3k/Lib/distutils/tests/test_build_clib.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_build_clib.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_build_clib.py	Thu May  7 23:24:43 2009
@@ -1,9 +1,12 @@
 """Tests for distutils.command.build_clib."""
 import unittest
+import os
+import sys
 
 from distutils.command.build_clib import build_clib
 from distutils.errors import DistutilsSetupError
 from distutils.tests import support
+from distutils.spawn import find_executable
 
 class BuildCLibTestCase(support.TempdirManager,
                         support.LoggingSilencer,
@@ -97,6 +100,43 @@
         cmd.distribution.libraries = 'WONTWORK'
         self.assertRaises(DistutilsSetupError, cmd.finalize_options)
 
+    def test_run(self):
+        # can't test on windows
+        if sys.platform == 'win32':
+            return
+
+        pkg_dir, dist = self.create_dist()
+        cmd = build_clib(dist)
+
+        foo_c = os.path.join(pkg_dir, 'foo.c')
+        self.write_file(foo_c, 'int main(void) { return 1;}')
+        cmd.libraries = [('foo', {'sources': [foo_c]})]
+
+        build_temp = os.path.join(pkg_dir, 'build')
+        os.mkdir(build_temp)
+        cmd.build_temp = build_temp
+        cmd.build_clib = build_temp
+
+        # 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
+        from distutils.sysconfig import customize_compiler
+
+        compiler = new_compiler()
+        customize_compiler(compiler)
+        for ccmd in compiler.executables.values():
+            if ccmd is None:
+                continue
+            if find_executable(ccmd[0]) is None:
+                return # can't test
+
+        # this should work
+        cmd.run()
+
+        # let's check the result
+        self.assert_('libfoo.a' in os.listdir(build_temp))
+
 def test_suite():
     return unittest.makeSuite(BuildCLibTestCase)
 

Modified: python/branches/py3k/Lib/distutils/tests/test_sysconfig.py
==============================================================================
--- python/branches/py3k/Lib/distutils/tests/test_sysconfig.py	(original)
+++ python/branches/py3k/Lib/distutils/tests/test_sysconfig.py	Thu May  7 23:24:43 2009
@@ -49,7 +49,8 @@
         if get_default_compiler() != 'unix':
             return
 
-        os.environ['AR'] = 'xxx'
+        os.environ['AR'] = 'my_ar'
+        os.environ['ARFLAGS'] = '-arflags'
 
         # make sure AR gets caught
         class compiler:
@@ -60,7 +61,7 @@
 
         comp = compiler()
         sysconfig.customize_compiler(comp)
-        self.assertEquals(comp.exes['archiver'], 'xxx')
+        self.assertEquals(comp.exes['archiver'], 'my_ar -arflags')
 
 
 def test_suite():

Modified: python/branches/py3k/Makefile.pre.in
==============================================================================
--- python/branches/py3k/Makefile.pre.in	(original)
+++ python/branches/py3k/Makefile.pre.in	Thu May  7 23:24:43 2009
@@ -67,6 +67,7 @@
 SGI_ABI=	@SGI_ABI@
 CCSHARED=	@CCSHARED@
 LINKFORSHARED=	@LINKFORSHARED@
+ARFLAGS=	@ARFLAGS@
 # Extra C flags added for building the interpreter object files.
 CFLAGSFORSHARED=@CFLAGSFORSHARED@
 # C flags used for building the interpreter object files
@@ -422,12 +423,12 @@
 # avoid long command lines, same as LIBRARY_OBJS
 $(LIBRARY): $(LIBRARY_OBJS)
 	-rm -f $@
-	$(AR) cr $@ Modules/getbuildinfo.o
-	$(AR) cr $@ $(PARSER_OBJS)
-	$(AR) cr $@ $(OBJECT_OBJS)
-	$(AR) cr $@ $(PYTHON_OBJS)
-	$(AR) cr $@ $(MODULE_OBJS) $(SIGNAL_OBJS)
-	$(AR) cr $@ $(MODOBJS)
+	$(AR) $(ARFLAGS) $@ Modules/getbuildinfo.o
+	$(AR) $(ARFLAGS) $@ $(PARSER_OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJECT_OBJS)
+	$(AR) $(ARFLAGS) $@ $(PYTHON_OBJS)
+	$(AR) $(ARFLAGS) $@ $(MODULE_OBJS) $(SIGNAL_OBJS)
+	$(AR) $(ARFLAGS) $@ $(MODOBJS)
 	$(RANLIB) $@
 
 libpython$(VERSION).so: $(LIBRARY_OBJS)

Modified: python/branches/py3k/Misc/ACKS
==============================================================================
--- python/branches/py3k/Misc/ACKS	(original)
+++ python/branches/py3k/Misc/ACKS	Thu May  7 23:24:43 2009
@@ -144,6 +144,7 @@
 David Costanzo
 Scott Cotton
 Greg Couch
+David Cournapeau
 Steve Cousins
 Alex Coventry
 Matthew Dixon Cowles

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Thu May  7 23:24:43 2009
@@ -581,6 +581,11 @@
 Library
 -------
 
+- Issue #5941: Distutils build_clib command was not working anymore because
+  of an incomplete costumization of the archiver command. Added ARFLAGS in the
+  Makefile besides AR and make Distutils use it. Original patch by David
+  Cournapeau.
+
 - Issue #2245: aifc now skips chunk types it doesn't recognize, per spec.
 
 - Issue #5874: distutils.tests.test_config_cmd is not locale-sensitive 

Modified: python/branches/py3k/configure.in
==============================================================================
--- python/branches/py3k/configure.in	(original)
+++ python/branches/py3k/configure.in	Thu May  7 23:24:43 2009
@@ -726,6 +726,13 @@
 AC_SUBST(AR)
 AC_CHECK_PROGS(AR, ar aal, ar)
 
+# tweak ARFLAGS only if the user didn't set it on the command line
+AC_SUBST(ARFLAGS)
+if test -z "$ARFLAGS"
+then
+        ARFLAGS="rc"
+fi
+
 AC_SUBST(SVNVERSION)
 AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
 if test $SVNVERSION = found


More information about the Python-checkins mailing list