summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Cournapeau <cournape@gmail.com>2010-09-17 11:43:53 +0900
committerDavid Cournapeau <cournape@gmail.com>2010-09-17 11:43:53 +0900
commite6eafde46153f827742e89c34a9f687b7416cab8 (patch)
tree4ae14f14d1fcd204c43464cc164a33ab3bf947dd
parentc952a9cd93344d0504508ccad13bcf818658e534 (diff)
downloadnumpy-e6eafde46153f827742e89c34a9f687b7416cab8.tar.gz
FEAT: add C module and f2py fortran wrapper output customization from command line.
-rw-r--r--numpy/f2py/capi_maps.py2
-rwxr-xr-xnumpy/f2py/f2py2e.py23
-rw-r--r--numpy/f2py/rules.py6
3 files changed, 25 insertions, 6 deletions
diff --git a/numpy/f2py/capi_maps.py b/numpy/f2py/capi_maps.py
index a3ab3e380..cba98af2b 100644
--- a/numpy/f2py/capi_maps.py
+++ b/numpy/f2py/capi_maps.py
@@ -643,6 +643,8 @@ def modsign2map(m):
else:
ret['interface_usercode'] = ''
ret['pymethoddef'] = getpymethoddef(m) or ''
+ ret['coutput'] = m['coutput']
+ ret['f2py_wrapper_output'] = m['f2py_wrapper_output']
return ret
def cb_sign2map(a,var,index=None):
diff --git a/numpy/f2py/f2py2e.py b/numpy/f2py/f2py2e.py
index 8c220565f..86c4b31a4 100755
--- a/numpy/f2py/f2py2e.py
+++ b/numpy/f2py/f2py2e.py
@@ -173,10 +173,9 @@ License: NumPy license (see LICENSE.txt in the NumPy source code)
Copyright 1999 - 2005 Pearu Peterson all rights reserved.
http://cens.ioc.ee/projects/f2py2e/"""%(f2py_version, numpy_version)
-
def scaninputline(inputline):
files,funcs,skipfuncs,onlyfuncs,debug=[],[],[],[],[]
- f,f2,f3,f4,f5,f6,f7=1,0,0,0,0,0,0
+ f,f2,f3,f4,f5,f6,f7,f8,f9=1,0,0,0,0,0,0,0,0
verbose = 1
dolc=-1
dolatexdoc = 0
@@ -185,7 +184,9 @@ def scaninputline(inputline):
buildpath = '.'
include_paths = []
signsfile,modulename=None,None
- options = {'buildpath':buildpath}
+ options = {'buildpath':buildpath,
+ 'coutput': None,
+ 'f2py_wrapper_output': None}
for l in inputline:
if l=='': pass
elif l=='only:': f=0
@@ -204,6 +205,8 @@ def scaninputline(inputline):
elif l=='--wrap-functions': wrapfuncs=1
elif l=='--no-wrap-functions': wrapfuncs=0
elif l=='--short-latex': options['shortlatex']=1
+ elif l=='--coutput': f8=1
+ elif l=='--f2py-wrapper-output': f9=1
elif l=='--overwrite-signature': options['h-overwrite']=1
elif l=='-h': f2=1
elif l=='-m': f3=1
@@ -224,6 +227,8 @@ def scaninputline(inputline):
elif f3: f3=0;modulename=l
elif f6: f6=0;buildpath=l
elif f7: f7=0;include_paths.extend(l.split(os.pathsep))
+ elif f8: f8=0;options["coutput"]=l
+ elif f9: f9=0;options["f2py_wrapper_output"]=l
elif f==1:
try:
open(l).close()
@@ -283,6 +288,18 @@ def callcrackfortran(files,options):
f=open(options['signsfile'],'w')
f.write(pyf)
f.close()
+ if options["coutput"] is None:
+ for mod in postlist:
+ mod["coutput"] = "%smodule.c" % mod["name"]
+ else:
+ for mod in postlist:
+ mod["coutput"] = options["coutput"]
+ if options["f2py_wrapper_output"] is None:
+ for mod in postlist:
+ mod["f2py_wrapper_output"] = "%s-f2pywrappers.f" % mod["name"]
+ else:
+ for mod in postlist:
+ mod["f2py_wrapper_output"] = options["f2py_wrapper_output"]
return postlist
def buildmodules(lst):
diff --git a/numpy/f2py/rules.py b/numpy/f2py/rules.py
index ae3871df5..62a80e25f 100644
--- a/numpy/f2py/rules.py
+++ b/numpy/f2py/rules.py
@@ -1216,12 +1216,12 @@ def buildmodule(m,um):
rd=dictappend(rd,ar)
ar=applyrules(module_rules,rd)
- fn = os.path.join(options['buildpath'],vrd['modulename']+'module.c')
+ fn = os.path.join(options['buildpath'],vrd['coutput'])
ret['csrc'] = fn
f=open(fn,'w')
f.write(ar['modulebody'].replace('\t',2*' '))
f.close()
- outmess('\tWrote C/API module "%s" to file "%s/%smodule.c"\n'%(m['name'],options['buildpath'],vrd['modulename']))
+ outmess('\tWrote C/API module "%s" to file "%s"\n'%(m['name'],fn))
if options['dorestdoc']:
fn = os.path.join(options['buildpath'],vrd['modulename']+'module.rest')
@@ -1243,7 +1243,7 @@ def buildmodule(m,um):
f.close()
outmess('\tDocumentation is saved to file "%s/%smodule.tex"\n'%(options['buildpath'],vrd['modulename']))
if funcwrappers:
- wn = os.path.join(options['buildpath'],'%s-f2pywrappers.f'%(vrd['modulename']))
+ wn = os.path.join(options['buildpath'],vrd['f2py_wrapper_output'])
ret['fsrc'] = wn
f=open(wn,'w')
f.write('C -*- fortran -*-\n')