diff options
author | Pauli Virtanen <pav@iki.fi> | 2010-03-06 19:39:09 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2010-03-06 19:39:09 +0000 |
commit | 8ed34403475e7e48232dfe3980b70eb057a2e2eb (patch) | |
tree | abe6c3cb1a96d01b31bd2d4b452fc9ec736c03de /numpy/f2py | |
parent | 9cccbf38bec50e3a3fd55c8884a70f302b34f66b (diff) | |
download | numpy-8ed34403475e7e48232dfe3980b70eb057a2e2eb.tar.gz |
3K: f2py: make f2py run far enough to produce output files (they don't compile yet, though, as the C code is not Py3 compatible)
Diffstat (limited to 'numpy/f2py')
-rw-r--r-- | numpy/f2py/auxfuncs.py | 42 | ||||
-rw-r--r-- | numpy/f2py/cb_rules.py | 2 | ||||
-rw-r--r-- | numpy/f2py/cfuncs.py | 2 | ||||
-rwxr-xr-x | numpy/f2py/f2py2e.py | 24 | ||||
-rw-r--r-- | numpy/f2py/tests/util.py | 8 |
5 files changed, 41 insertions, 37 deletions
diff --git a/numpy/f2py/auxfuncs.py b/numpy/f2py/auxfuncs.py index 3121f710e..ac95669b7 100644 --- a/numpy/f2py/auxfuncs.py +++ b/numpy/f2py/auxfuncs.py @@ -590,22 +590,22 @@ def stripcomma(s): if s and s[-1]==',': return s[:-1] return s -def replace(str,dict,defaultsep=''): - if type(dict)==types.ListType: - return map(lambda d,f=replace,sep=defaultsep,s=str:f(s,d,sep),dict) +def replace(str,d,defaultsep=''): + if type(d)==types.ListType: + return map(lambda d,f=replace,sep=defaultsep,s=str:f(s,d,sep),d) if type(str)==types.ListType: - return map(lambda s,f=replace,sep=defaultsep,d=dict:f(s,d,sep),str) - for k in 2*dict.keys(): + return map(lambda s,f=replace,sep=defaultsep,d=d:f(s,d,sep),str) + for k in 2*d.keys(): if k=='separatorsfor': continue - if 'separatorsfor' in dict and k in dict['separatorsfor']: - sep=dict['separatorsfor'][k] + if 'separatorsfor' in d and k in d['separatorsfor']: + sep=d['separatorsfor'][k] else: sep=defaultsep - if type(dict[k])==types.ListType: - str=str.replace('#%s#'%(k),sep.join(flatlist(dict[k]))) + if type(d[k])==types.ListType: + str=str.replace('#%s#'%(k),sep.join(flatlist(d[k]))) else: - str=str.replace('#%s#'%(k),dict[k]) + str=str.replace('#%s#'%(k),d[k]) return str def dictappend(rd,ar): @@ -617,7 +617,7 @@ def dictappend(rd,ar): if k[0]=='_': continue if k in rd: - if type(rd[k])==types.StringType: + if type(rd[k])==str: rd[k]=[rd[k]] if type(rd[k])==types.ListType: if type(ar[k])==types.ListType: @@ -636,11 +636,11 @@ def dictappend(rd,ar): rd[k]=ar[k] return rd -def applyrules(rules,dict,var={}): +def applyrules(rules,d,var={}): ret={} if type(rules)==types.ListType: for r in rules: - rr=applyrules(r,dict,var) + rr=applyrules(r,d,var) ret=dictappend(ret,rr) if '_break' in rr: break @@ -648,19 +648,19 @@ def applyrules(rules,dict,var={}): if '_check' in rules and (not rules['_check'](var)): return ret if 'need' in rules: - res = applyrules({'needs':rules['need']},dict,var) + res = applyrules({'needs':rules['need']},d,var) if 'needs' in res: cfuncs.append_needs(res['needs']) for k in rules.keys(): if k=='separatorsfor': ret[k]=rules[k]; continue - if type(rules[k])==types.StringType: - ret[k]=replace(rules[k],dict) + if type(rules[k])==str: + ret[k]=replace(rules[k],d) elif type(rules[k])==types.ListType: ret[k]=[] for i in rules[k]: - ar=applyrules({k:i},dict,var) + ar=applyrules({k:i},d,var) if k in ar: ret[k].append(ar[k]) elif k[0]=='_': @@ -672,19 +672,19 @@ def applyrules(rules,dict,var={}): if type(rules[k][k1])==types.ListType: for i in rules[k][k1]: if type(i)==types.DictType: - res=applyrules({'supertext':i},dict,var) + res=applyrules({'supertext':i},d,var) if 'supertext' in res: i=res['supertext'] else: i='' - ret[k].append(replace(i,dict)) + ret[k].append(replace(i,d)) else: i=rules[k][k1] if type(i)==types.DictType: - res=applyrules({'supertext':i},dict) + res=applyrules({'supertext':i},d) if 'supertext' in res: i=res['supertext'] else: i='' - ret[k].append(replace(i,dict)) + ret[k].append(replace(i,d)) else: errmess('applyrules: ignoring rule %s.\n'%`rules[k]`) if type(ret[k])==types.ListType: diff --git a/numpy/f2py/cb_rules.py b/numpy/f2py/cb_rules.py index 6e5502137..99742cb46 100644 --- a/numpy/f2py/cb_rules.py +++ b/numpy/f2py/cb_rules.py @@ -515,7 +515,7 @@ def buildcallback(rout,um): ar=applyrules(cb_routine_rules,rd) cfuncs.callbacks[rd['name']]=ar['body'] - if type(ar['need'])==types.StringType: + if type(ar['need'])==str: ar['need']=[ar['need']] if 'need' in rd: diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py index ec448680d..2d33c90b5 100644 --- a/numpy/f2py/cfuncs.py +++ b/numpy/f2py/cfuncs.py @@ -1075,7 +1075,7 @@ def append_needs(need,flag=1): if type(need)==types.ListType: for n in need: append_needs(n,flag) - elif type(need)==types.StringType: + elif type(need)==str: if not need: return if need in includes0: n = 'includes0' diff --git a/numpy/f2py/f2py2e.py b/numpy/f2py/f2py2e.py index 264a01312..8c220565f 100755 --- a/numpy/f2py/f2py2e.py +++ b/numpy/f2py/f2py2e.py @@ -285,21 +285,21 @@ def callcrackfortran(files,options): f.close() return postlist -def buildmodules(list): +def buildmodules(lst): cfuncs.buildcfuncs() outmess('Building modules...\n') modules,mnames,isusedby=[],[],{} - for i in range(len(list)): - if '__user__' in list[i]['name']: - cb_rules.buildcallbacks(list[i]) + for i in range(len(lst)): + if '__user__' in lst[i]['name']: + cb_rules.buildcallbacks(lst[i]) else: - if 'use' in list[i]: - for u in list[i]['use'].keys(): + if 'use' in lst[i]: + for u in lst[i]['use'].keys(): if u not in isusedby: isusedby[u]=[] - isusedby[u].append(list[i]['name']) - modules.append(list[i]) - mnames.append(list[i]['name']) + isusedby[u].append(lst[i]['name']) + modules.append(lst[i]) + mnames.append(lst[i]['name']) ret = {} for i in range(len(mnames)): if mnames[i] in isusedby: @@ -329,7 +329,11 @@ def run_main(comline_list): """Run f2py as if string.join(comline_list,' ') is used as a command line. In case of using -h flag, return None. """ - reload(crackfortran) + if sys.version_info[0] >= 3: + import imp + imp.reload(crackfortran) + else: + reload(crackfortran) f2pydir=os.path.dirname(os.path.abspath(cfuncs.__file__)) fobjhsrc = os.path.join(f2pydir,'src','fortranobject.h') fobjcsrc = os.path.join(f2pydir,'src','fortranobject.c') diff --git a/numpy/f2py/tests/util.py b/numpy/f2py/tests/util.py index 4895dc7ca..11cf611ce 100644 --- a/numpy/f2py/tests/util.py +++ b/numpy/f2py/tests/util.py @@ -18,7 +18,7 @@ import random import nose -from numpy.compat import asbytes +from numpy.compat import asbytes, asstr import numpy.f2py try: @@ -125,7 +125,7 @@ def build_module(source_files, options=[], skip=[], only=[], module_name=None): out, err = p.communicate() if p.returncode != 0: raise RuntimeError("Running f2py failed: %s\n%s" - % (cmd[4:], out)) + % (cmd[4:], asstr(out))) finally: os.chdir(cwd) @@ -203,7 +203,7 @@ sys.exit(99) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) out, err = p.communicate() - m = re.search(r'COMPILERS:(\d+),(\d+),(\d+)', out) + m = re.search(asbytes(r'COMPILERS:(\d+),(\d+),(\d+)'), out) if m: _compiler_status = (bool(m.group(1)), bool(m.group(2)), bool(m.group(3))) @@ -281,7 +281,7 @@ if __name__ == "__main__": out, err = p.communicate() if p.returncode != 0: raise RuntimeError("Running distutils build failed: %s\n%s" - % (cmd[4:], out)) + % (cmd[4:], asstr(out))) finally: os.chdir(cwd) |