summaryrefslogtreecommitdiff
path: root/numpy/distutils/unixccompiler.py
diff options
context:
space:
mode:
authorcookedm <cookedm@localhost>2007-08-17 18:29:08 +0000
committercookedm <cookedm@localhost>2007-08-17 18:29:08 +0000
commit83f13bc82583855d024788b4d27707bdf2cb315b (patch)
tree3db2e362e2295dbf9ad97f16116589bced65aaa1 /numpy/distutils/unixccompiler.py
parent4400da25e2b796727076add0799fddda4f475700 (diff)
downloadnumpy-83f13bc82583855d024788b4d27707bdf2cb315b.tar.gz
- remove .a static libs and recreate, instead of updating (ar on OS X can't
handle updating universal .a) - in unixccompiler, use ccompiler.replace_method instead of new.instance_method
Diffstat (limited to 'numpy/distutils/unixccompiler.py')
-rw-r--r--numpy/distutils/unixccompiler.py28
1 files changed, 17 insertions, 11 deletions
diff --git a/numpy/distutils/unixccompiler.py b/numpy/distutils/unixccompiler.py
index cc3154114..416bffc82 100644
--- a/numpy/distutils/unixccompiler.py
+++ b/numpy/distutils/unixccompiler.py
@@ -3,10 +3,10 @@ unixccompiler - can handle very long argument lists for ar.
"""
import os
-import new
from distutils.errors import DistutilsExecError, CompileError
from distutils.unixccompiler import *
+from numpy.distutils.ccompiler import replace_method
import log
@@ -18,26 +18,33 @@ def UnixCCompiler__compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts
extra_postargs, display = display)
except DistutilsExecError, msg:
raise CompileError, msg
-UnixCCompiler._compile = new.instancemethod(UnixCCompiler__compile,
- None,
- UnixCCompiler)
+replace_method(UnixCCompiler, '_compile', UnixCCompiler__compile)
-def UnixCCompile_create_static_lib(self, objects, output_libname,
- output_dir=None, debug=0, target_lang=None):
+
+def UnixCCompiler_create_static_lib(self, objects, output_libname,
+ output_dir=None, debug=0, target_lang=None):
objects, output_dir = self._fix_object_args(objects, output_dir)
output_filename = \
self.library_filename(output_libname, output_dir=output_dir)
if self._need_link(objects, output_filename):
+ try:
+ # previous .a may be screwed up; best to remove it first
+ # and recreate.
+ # Also, ar on OS X doesn't handle updating universal archives
+ os.unlink(output_filename)
+ except (IOError, OSError):
+ pass
self.mkpath(os.path.dirname(output_filename))
tmp_objects = objects + self.objects
while tmp_objects:
objects = tmp_objects[:50]
tmp_objects = tmp_objects[50:]
- display = '%s: adding %d object files to %s' % (os.path.basename(self.archiver[0]),
- len(objects),output_filename)
+ display = '%s: adding %d object files to %s' % (
+ os.path.basename(self.archiver[0]),
+ len(objects), output_filename)
self.spawn(self.archiver + [output_filename] + objects,
display = display)
@@ -58,6 +65,5 @@ def UnixCCompile_create_static_lib(self, objects, output_libname,
log.debug("skipping %s (up-to-date)", output_filename)
return
-UnixCCompiler.create_static_lib = \
- new.instancemethod(UnixCCompile_create_static_lib,
- None,UnixCCompiler)
+replace_method(UnixCCompiler, 'create_static_lib',
+ UnixCCompiler_create_static_lib)