summaryrefslogtreecommitdiff
path: root/numpy/f2py/f2py2e.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/f2py/f2py2e.py')
-rwxr-xr-xnumpy/f2py/f2py2e.py84
1 files changed, 42 insertions, 42 deletions
diff --git a/numpy/f2py/f2py2e.py b/numpy/f2py/f2py2e.py
index 64c13fff0..011b430d5 100755
--- a/numpy/f2py/f2py2e.py
+++ b/numpy/f2py/f2py2e.py
@@ -173,8 +173,8 @@ Copyright 1999 - 2011 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,f8,f9=1,0,0,0,0,0,0,0,0
+ files, funcs, skipfuncs, onlyfuncs, debug=[], [], [], [], []
+ f, f2, f3, f4, f5, f6, f7, f8, f9=1, 0, 0, 0, 0, 0, 0, 0, 0
verbose = 1
dolc=-1
dolatexdoc = 0
@@ -182,7 +182,7 @@ def scaninputline(inputline):
wrapfuncs = 1
buildpath = '.'
include_paths = []
- signsfile,modulename=None,None
+ signsfile, modulename=None, None
options = {'buildpath':buildpath,
'coutput': None,
'f2py_wrapper_output': None}
@@ -236,7 +236,7 @@ def scaninputline(inputline):
open(l).close()
files.append(l)
except IOError as detail:
- errmess('IOError: %s. Skipping file "%s".\n'%(str(detail),l))
+ errmess('IOError: %s. Skipping file "%s".\n'%(str(detail), l))
elif f==-1: skipfuncs.append(l)
elif f==0: onlyfuncs.append(l)
if not f5 and not files and not modulename:
@@ -247,7 +247,7 @@ def scaninputline(inputline):
outmess('Creating build directory %s'%(buildpath))
os.mkdir(buildpath)
if signsfile:
- signsfile = os.path.join(buildpath,signsfile)
+ signsfile = os.path.join(buildpath, signsfile)
if signsfile and os.path.isfile(signsfile) and 'h-overwrite' not in options:
errmess('Signature file "%s" exists!!! Use --overwrite-signature to overwrite.\n'%(signsfile))
sys.exit()
@@ -265,9 +265,9 @@ def scaninputline(inputline):
options['wrapfuncs'] = wrapfuncs
options['buildpath']=buildpath
options['include_paths']=include_paths
- return files,options
+ return files, options
-def callcrackfortran(files,options):
+def callcrackfortran(files, options):
rules.options=options
funcs=[]
crackfortran.debug=options['debug']
@@ -287,7 +287,7 @@ def callcrackfortran(files,options):
if options['signsfile'][-6:]=='stdout':
sys.stdout.write(pyf)
else:
- f=open(options['signsfile'],'w')
+ f=open(options['signsfile'], 'w')
f.write(pyf)
f.close()
if options["coutput"] is None:
@@ -307,7 +307,7 @@ def callcrackfortran(files,options):
def buildmodules(lst):
cfuncs.buildcfuncs()
outmess('Building modules...\n')
- modules,mnames,isusedby=[],[],{}
+ modules, mnames, isusedby=[], [], {}
for i in range(len(lst)):
if '__user__' in lst[i]['name']:
cb_rules.buildcallbacks(lst[i])
@@ -322,7 +322,7 @@ def buildmodules(lst):
ret = {}
for i in range(len(mnames)):
if mnames[i] in isusedby:
- outmess('\tSkipping module "%s" which is used by %s.\n'%(mnames[i],','.join(['"%s"'%s for s in isusedby[mnames[i]]])))
+ outmess('\tSkipping module "%s" which is used by %s.\n'%(mnames[i], ','.join(['"%s"'%s for s in isusedby[mnames[i]]])))
else:
um=[]
if 'use' in modules[i]:
@@ -330,13 +330,13 @@ def buildmodules(lst):
if u in isusedby and u in mnames:
um.append(modules[mnames.index(u)])
else:
- outmess('\tModule "%s" uses nonexisting "%s" which will be ignored.\n'%(mnames[i],u))
+ outmess('\tModule "%s" uses nonexisting "%s" which will be ignored.\n'%(mnames[i], u))
ret[mnames[i]] = {}
- dict_append(ret[mnames[i]],rules.buildmodule(modules[i],um))
+ dict_append(ret[mnames[i]], rules.buildmodule(modules[i], um))
return ret
-def dict_append(d_out,d_in):
- for (k,v) in d_in.items():
+def dict_append(d_out, d_in):
+ for (k, v) in d_in.items():
if k not in d_out:
d_out[k] = []
if isinstance(v, list):
@@ -354,11 +354,11 @@ def run_main(comline_list):
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')
- files,options=scaninputline(comline_list)
+ fobjhsrc = os.path.join(f2pydir, 'src', 'fortranobject.h')
+ fobjcsrc = os.path.join(f2pydir, 'src', 'fortranobject.c')
+ files, options=scaninputline(comline_list)
auxfuncs.options=options
- postlist=callcrackfortran(files,options)
+ postlist=callcrackfortran(files, options)
isusedby={}
for i in range(len(postlist)):
if 'use' in postlist[i]:
@@ -370,11 +370,11 @@ def run_main(comline_list):
if postlist[i]['block']=='python module' and '__user__' in postlist[i]['name']:
if postlist[i]['name'] in isusedby:
#if not quiet:
- outmess('Skipping Makefile build for module "%s" which is used by %s\n'%(postlist[i]['name'],','.join(['"%s"'%s for s in isusedby[postlist[i]['name']]])))
+ outmess('Skipping Makefile build for module "%s" which is used by %s\n'%(postlist[i]['name'], ','.join(['"%s"'%s for s in isusedby[postlist[i]['name']]])))
if 'signsfile' in options:
if options['verbose']>1:
outmess('Stopping. Edit the signature file and then run f2py on the signature file: ')
- outmess('%s %s\n'%(os.path.basename(sys.argv[0]),options['signsfile']))
+ outmess('%s %s\n'%(os.path.basename(sys.argv[0]), options['signsfile']))
return
for i in range(len(postlist)):
if postlist[i]['block']!='python module':
@@ -388,14 +388,14 @@ def run_main(comline_list):
ret=buildmodules(postlist)
for mn in ret.keys():
- dict_append(ret[mn],{'csrc':fobjcsrc,'h':fobjhsrc})
+ dict_append(ret[mn], {'csrc':fobjcsrc,'h':fobjhsrc})
return ret
def filter_files(prefix,suffix,files,remove_prefix=None):
"""
Filter files by prefix and suffix.
"""
- filtered,rest = [],[]
+ filtered, rest = [], []
match = re.compile(prefix+r'.*'+suffix+r'\Z').match
if remove_prefix:
ind = len(prefix)
@@ -404,7 +404,7 @@ def filter_files(prefix,suffix,files,remove_prefix=None):
for file in [x.strip() for x in files]:
if match(file): filtered.append(file[ind:])
else: rest.append(file)
- return filtered,rest
+ return filtered, rest
def get_prefix(module):
p = os.path.dirname(os.path.dirname(module.__file__))
@@ -442,7 +442,7 @@ def run_compile():
f2py_flags2 = []
fl = 0
for a in sys.argv[1:]:
- if a in ['only:','skip:']:
+ if a in ['only:', 'skip:']:
fl = 1
elif a==':':
fl = 0
@@ -483,7 +483,7 @@ def run_compile():
for s in del_list:
i = flib_flags.index(s)
del flib_flags[i]
- assert len(flib_flags)<=2,repr(flib_flags)
+ assert len(flib_flags)<=2, repr(flib_flags)
_reg5 = re.compile(r'[-][-](verbose)')
setup_flags = [_m for _m in sys.argv[1:] if _reg5.match(_m)]
@@ -499,39 +499,39 @@ def run_compile():
if optname in sys.argv:
i = sys.argv.index (optname)
f2py_flags.extend (sys.argv[i:i+2])
- del sys.argv[i+1],sys.argv[i]
+ del sys.argv[i+1], sys.argv[i]
sources = sys.argv[1:]
if '-m' in sys.argv:
i = sys.argv.index('-m')
modulename = sys.argv[i+1]
- del sys.argv[i+1],sys.argv[i]
+ del sys.argv[i+1], sys.argv[i]
sources = sys.argv[1:]
else:
from numpy.distutils.command.build_src import get_f2py_modulename
- pyf_files,sources = filter_files('','[.]pyf([.]src|)',sources)
+ pyf_files, sources = filter_files('', '[.]pyf([.]src|)', sources)
sources = pyf_files + sources
for f in pyf_files:
modulename = get_f2py_modulename(f)
if modulename:
break
- extra_objects, sources = filter_files('','[.](o|a|so)',sources)
- include_dirs, sources = filter_files('-I','',sources,remove_prefix=1)
- library_dirs, sources = filter_files('-L','',sources,remove_prefix=1)
- libraries, sources = filter_files('-l','',sources,remove_prefix=1)
- undef_macros, sources = filter_files('-U','',sources,remove_prefix=1)
- define_macros, sources = filter_files('-D','',sources,remove_prefix=1)
+ extra_objects, sources = filter_files('', '[.](o|a|so)', sources)
+ include_dirs, sources = filter_files('-I', '', sources, remove_prefix=1)
+ library_dirs, sources = filter_files('-L', '', sources, remove_prefix=1)
+ libraries, sources = filter_files('-l', '', sources, remove_prefix=1)
+ undef_macros, sources = filter_files('-U', '', sources, remove_prefix=1)
+ define_macros, sources = filter_files('-D', '', sources, remove_prefix=1)
using_numarray = 0
using_numeric = 0
for i in range(len(define_macros)):
- name_value = define_macros[i].split('=',1)
+ name_value = define_macros[i].split('=', 1)
if len(name_value)==1:
name_value.append(None)
if len(name_value)==2:
define_macros[i] = tuple(name_value)
else:
- print('Invalid use of -D:',name_value)
+ print('Invalid use of -D:', name_value)
from numpy.distutils.system_info import get_info
@@ -544,10 +544,10 @@ def run_compile():
#num_info = {'include_dirs': get_numpy_include_dirs()}
if num_info:
- include_dirs.extend(num_info.get('include_dirs',[]))
+ include_dirs.extend(num_info.get('include_dirs', []))
- from numpy.distutils.core import setup,Extension
- ext_args = {'name':modulename,'sources':sources,
+ from numpy.distutils.core import setup, Extension
+ ext_args = {'name': modulename, 'sources': sources,
'include_dirs': include_dirs,
'library_dirs': library_dirs,
'libraries': libraries,
@@ -569,9 +569,9 @@ def run_compile():
ext = Extension(**ext_args)
sys.argv = [sys.argv[0]] + setup_flags
sys.argv.extend(['build',
- '--build-temp',build_dir,
- '--build-base',build_dir,
- '--build-platlib','.'])
+ '--build-temp', build_dir,
+ '--build-base', build_dir,
+ '--build-platlib', '.'])
if fc_flags:
sys.argv.extend(['config_fc']+fc_flags)
if flib_flags: