diff --git a/pywafo/build_all.py b/pywafo/build_all.py index 5707249..dcdd45e 100644 --- a/pywafo/build_all.py +++ b/pywafo/build_all.py @@ -10,7 +10,22 @@ def compile_all(): root_dir = os.path.join(wd,'src',pkg_name) root_src = os.path.join(root_dir, 'source') buildscript = 'build_all.py' - build_call = buildfile ='python.exe %s' % buildscript + + # if Linux + if os.name == 'posix': + build_call = 'python %s' % buildscript + lib_ext = '.so' + + # On Windows + elif os.name == 'nt': + build_call = 'python.exe %s' % buildscript + lib_ext = '.pyd' + + # give an Error for other OS-es + else: + raise UserWarning, \ + 'Untested platform:', os.name + for root, dirs, files in os.walk(root_src): dir1 = [dir for dir in dirs if not os.path.exists(os.path.join(root,dir,buildscript))] for dir in dir1: @@ -23,7 +38,7 @@ def compile_all(): print(t) for file in os.listdir('.'): - if file.endswith('.pyd'): + if file.endswith(lib_ext): dest_file = os.path.join(root_dir, file) if os.path.exists(dest_file): os.remove(dest_file) diff --git a/pywafo/setup.py b/pywafo/setup.py index 2215141..27b7bbe 100644 --- a/pywafo/setup.py +++ b/pywafo/setup.py @@ -118,9 +118,24 @@ if __name__=='__main__': if not (f.startswith('.') or f.endswith('~') or f.endswith('.old') or f.endswith('.bak') or f.endswith('.py') or f.endswith('test') )] - libs = [f for f in os.listdir(os.path.join(root_dir)) if f.endswith('.pyd') ] - packagedata = testscripts + datafiles + libs #['c_library.pyd'] #,'disufq1.c','diffsumfunq.pyd','diffsumfunq.pyf','findrfc.c','rfc.pyd','rfc.pyf'] + # executable library on Linux has extension .so + if os.name == 'posix': + lib_ext = '.so' + + # extension on Windows is .pyd + elif os.name == 'nt': + lib_ext = '.pyd' + + # give an Error for other OS-es + else: + raise UserWarning, \ + 'Platform not supported:', os.name + + libs = [f for f in os.listdir(os.path.join(root_dir)) if f.endswith(lib_ext) ] +# libs = [f for f in os.listdir(os.path.join(root_dir)) if f.endswith('.pyd') ] + + packagedata = testscripts + datafiles + libs #['c_library.pyd'] #,'disufq1.c','diffsumfunq.pyd','diffsumfunq.pyf','findrfc.c','rfc.pyd','rfc.pyf'] setup( version = VERSION, diff --git a/pywafo/src/wafo/c_library.so b/pywafo/src/wafo/c_library.so new file mode 100755 index 0000000..3ddfc76 Binary files /dev/null and b/pywafo/src/wafo/c_library.so differ diff --git a/pywafo/src/wafo/mvn.so b/pywafo/src/wafo/mvn.so new file mode 100755 index 0000000..05e048e Binary files /dev/null and b/pywafo/src/wafo/mvn.so differ diff --git a/pywafo/src/wafo/mvnprdmod.so b/pywafo/src/wafo/mvnprdmod.so new file mode 100755 index 0000000..b3960ce Binary files /dev/null and b/pywafo/src/wafo/mvnprdmod.so differ diff --git a/pywafo/src/wafo/rindmod.so b/pywafo/src/wafo/rindmod.so new file mode 100755 index 0000000..d611e70 Binary files /dev/null and b/pywafo/src/wafo/rindmod.so differ diff --git a/pywafo/src/wafo/source/c_codes/build_all.py b/pywafo/src/wafo/source/c_codes/build_all.py index 3422bc4..75cf954 100644 --- a/pywafo/src/wafo/source/c_codes/build_all.py +++ b/pywafo/src/wafo/source/c_codes/build_all.py @@ -6,16 +6,29 @@ See also http://www.scipy.org/Cookbook/CompilingExtensionsOnWindowsWithMinGW import os def compile_all(): - # Install gfortran and run the following to build the module: - #compile_format = 'f2py.py %s %s -c --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71' - + + # on Linux my linux version it is f2py2.6, don't know how that is on others + if os.name == 'posix': + # this might vary among specific cases: f2py, f2py2.7, f2py3.2, ... + # TODO: more robust approach, find out what f2py is in the users path + compile_format = 'f2py2.6 %s %s -c' + # Install microsoft visual c++ .NET 2003 and run the following to build the module: - compile_format = 'f2py.py %s %s -c' + elif os.name == 'nt': + # compile_format = 'f2py.py %s %s -c --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71' + compile_format = 'f2py.py %s %s -c' + + # give an Error for other OS-es + else: + raise UserWarning, \ + 'Untested platform:', os.name + pyfs = ('c_library.pyf',) files =('c_functions.c',) for pyf,file in zip(pyfs,files): os.system(compile_format % (pyf,file)) +# f2py.py c_library.pyf c_functions.c -c if __name__=='__main__': compile_all() diff --git a/pywafo/src/wafo/source/mvn/build_all.py b/pywafo/src/wafo/source/mvn/build_all.py index a5b06aa..a56482e 100644 --- a/pywafo/src/wafo/source/mvn/build_all.py +++ b/pywafo/src/wafo/source/mvn/build_all.py @@ -4,8 +4,25 @@ builds mvn.pyd import os def compile_all(): + #os.system('f2py.py mvn.pyf mvndst.f -c --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71 ') - os.system('f2py.py mvn.pyf mvndst.f -c ') + + # this might vary among specific cases: f2py, f2py2.7, f2py3.2, ... + # TODO: more robust approach, find out what f2py is in the users path + if os.name == 'posix': + f2py_call = 'f2py2.6' + + # Install microsoft visual c++ .NET 2003 and run the following to build the module: + elif os.name == 'nt': + f2py_call = 'f2py.py' + + # give an Error for other OS-es + else: + raise UserWarning, \ + 'Untested platform:', os.name + + os.system(f2py_call + ' mvn.pyf mvndst.f -c ') + if __name__=='__main__': compile_all() diff --git a/pywafo/src/wafo/source/mvnprd/build_all.py b/pywafo/src/wafo/source/mvnprd/build_all.py index 279e606..683584e 100644 --- a/pywafo/src/wafo/source/mvnprd/build_all.py +++ b/pywafo/src/wafo/source/mvnprd/build_all.py @@ -10,8 +10,22 @@ def compile_all(): os.system(compile1_format % file) file_objects = '%s.o %s.o' % tuple(files) + # this might vary among specific cases: f2py, f2py2.7, f2py3.2, ... + # TODO: more robust approach, find out what f2py is in the users path + if os.name == 'posix': + f2py_call = 'f2py2.6' + + # Install microsoft visual c++ .NET 2003 and run the following to build the module: + elif os.name == 'nt': + f2py_call = 'f2py.py' + + # give an Error for other OS-es + else: + raise UserWarning, \ + 'Untested platform:', os.name + #os.system('f2py.py -m mvnprdmod -c %s mvnprd_interface.f --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71' % file_objects) - os.system('f2py.py -m mvnprdmod -c %s mvnprd_interface.f ' % file_objects) + os.system(f2py_call + ' -m mvnprdmod -c %s mvnprd_interface.f ' % file_objects) if __name__=='__main__': compile_all() diff --git a/pywafo/src/wafo/source/rind2007/build_all.py b/pywafo/src/wafo/source/rind2007/build_all.py index 86487e6..8b2d358 100644 --- a/pywafo/src/wafo/source/rind2007/build_all.py +++ b/pywafo/src/wafo/source/rind2007/build_all.py @@ -11,7 +11,21 @@ def compile_all(): os.system(compile1_format % file) file_objects = format1 % tuple(files) - os.system('f2py.py -m rindmod -c %s rind_interface.f ' % file_objects) + # this might vary among specific cases: f2py, f2py2.7, f2py3.2, ... + # TODO: more robust approach, find out what f2py is in the users path + if os.name == 'posix': + f2py_call = 'f2py2.6' + + # Install microsoft visual c++ .NET 2003 and run the following to build the module: + elif os.name == 'nt': + f2py_call = 'f2py.py' + + # give an Error for other OS-es + else: + raise UserWarning, \ + 'Untested platform:', os.name + + os.system(f2py_call + ' -m rindmod -c %s rind_interface.f ' % file_objects) if __name__=='__main__': compile_all()