summaryrefslogtreecommitdiff
path: root/numpy/distutils/command/build_src.py
diff options
context:
space:
mode:
authorPearu Peterson <pearu.peterson@gmail.com>2010-08-25 08:41:58 +0000
committerPearu Peterson <pearu.peterson@gmail.com>2010-08-25 08:41:58 +0000
commita1b13e177d30d80c34897aa55352499785206e7d (patch)
tree0a293844fd226ff6188418313249d5e2bd930c94 /numpy/distutils/command/build_src.py
parentff0822c48fb6cc1689a92038d579988c2db2f154 (diff)
downloadnumpy-a1b13e177d30d80c34897aa55352499785206e7d.tar.gz
Fix swig target extension when swig target is not defined by the .i file but should be c++.
Diffstat (limited to 'numpy/distutils/command/build_src.py')
-rw-r--r--numpy/distutils/command/build_src.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/numpy/distutils/command/build_src.py b/numpy/distutils/command/build_src.py
index c3acccb3b..ae29aec0e 100644
--- a/numpy/distutils/command/build_src.py
+++ b/numpy/distutils/command/build_src.py
@@ -656,6 +656,8 @@ class build_src(build_ext.build_ext):
for source in sources:
(base, ext) = os.path.splitext(source)
if ext == '.i': # SWIG interface file
+ # the code below assumes that the sources list
+ # contains not more than one .i SWIG interface file
if self.inplace:
target_dir = os.path.dirname(base)
py_target_dir = self.ext_target_dir
@@ -671,10 +673,16 @@ class build_src(build_ext.build_ext):
if typ is None:
typ = get_swig_target(source)
is_cpp = typ=='c++'
- if is_cpp: target_ext = '.cpp'
+ if is_cpp:
+ target_ext = '.cpp'
else:
typ2 = get_swig_target(source)
- if typ!=typ2:
+ if typ2 is None:
+ log.warn('source %r does not define swig target, assuming %s swig target' \
+ % (source, typ))
+ if is_cpp:
+ target_ext = '.cpp'
+ elif typ!=typ2:
log.warn('expected %r but source %r defines %r swig target' \
% (typ, source, typ2))
if typ2=='c++':
@@ -750,7 +758,7 @@ _has_cpp_header = re.compile(r'-[*]-\s*c[+][+]\s*-[*]-',re.I).search
def get_swig_target(source):
f = open(source,'r')
- result = 'c'
+ result = None
line = f.readline()
if _has_cpp_header(line):
result = 'c++'