diff --git a/pywafo/src/wafo/source/c_codes/build_all.py b/pywafo/src/wafo/source/c_codes/build_all.py index b0b8f37..43b93a2 100644 --- a/pywafo/src/wafo/source/c_codes/build_all.py +++ b/pywafo/src/wafo/source/c_codes/build_all.py @@ -4,6 +4,7 @@ f2py c_library.pyf c_functions.c -c See also http://www.scipy.org/Cookbook/CompilingExtensionsOnWindowsWithMinGW """ import os +import sys def which(program): """ @@ -21,7 +22,7 @@ def which(program): def is_exe(fpath): return os.path.exists(fpath) and os.access(fpath, os.X_OK) - + fpath, unused_fname = os.path.split(program) if fpath: if is_exe(program): @@ -31,35 +32,39 @@ def which(program): exe_file = os.path.join(path, program) if is_exe(exe_file): return exe_file - + return None def f2py_call_str(): # regardless of platform, try to figure out which f2py call is in the path # define possible options - f2py_call_list = ('f2py','f2py2.6','f2py2.7','f2py.py',) - - no_f2py = True - for k in f2py_call_list: - # if the call command exists in the path, it will return the path as - # a string, otherwise it will return None - f2py_path = which(k) - no_f2py = not f2py_path - if no_f2py: - # didn't find the current call k, continue looking - pass - else: - # current call k is in the path - f2py_call = k - break - # raise exception if f2py is not found - if no_f2py: - raise UserWarning, \ - 'Couldn\'t locate f2py. Should be part of NumPy installation.' + # on Arch Linux, python and f2py are the calls corresponding to python 3 + # and python2/f2py2 for python 2 + # other Linux versions might still use python/f2py for python 2 + if os.path.basename(sys.executable).endswith('2'): + for k in ('f2py2','f2py2.6','f2py2.7',): + # if we found the f2py path, no need to look further + if which(k): + f2py_call = k + f2py_path = which(k) + break + # on Windows and other Linux using python/f2py else: + for k in ('f2py','f2py2.6','f2py2.7','f2py.py',): + # if we found the f2py path, no need to look further + if which(k): + f2py_call = k + f2py_path = which(k) + break + + try: print 'found f2py in:', f2py_path return f2py_call + # raise exception if f2py is not found, f2py_path variable will not exist + except NameError: + raise UserWarning, \ + 'Couldn\'t locate f2py. Should be part of NumPy installation.' # # 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': diff --git a/pywafo/src/wafo/source/mreg/build_all.py b/pywafo/src/wafo/source/mreg/build_all.py index a135186..a3ebb32 100644 --- a/pywafo/src/wafo/source/mreg/build_all.py +++ b/pywafo/src/wafo/source/mreg/build_all.py @@ -5,6 +5,7 @@ gfortran -W -Wall -pedantic-errors -fbounds-check -Werror -c dsvdc.f mregmodule. """ import os +import sys def which(program): """ @@ -38,29 +39,33 @@ def which(program): def f2py_call_str(): # regardless of platform, try to figure out which f2py call is in the path # define possible options - f2py_call_list = ('f2py','f2py2.6','f2py2.7','f2py.py',) - no_f2py = True - for k in f2py_call_list: - # if the call command exists in the path, it will return the path as - # a string, otherwise it will return None - f2py_path = which(k) - no_f2py = not f2py_path - if no_f2py: - # didn't find the current call k, continue looking - pass - else: - # current call k is in the path - f2py_call = k - break - - # raise exception if f2py is not found - if no_f2py: - raise UserWarning, \ - 'Couldn\'t locate f2py. Should be part of NumPy installation.' + # on Arch Linux, python and f2py are the calls corresponding to python 3 + # and python2/f2py2 for python 2 + # other Linux versions might still use python/f2py for python 2 + if os.path.basename(sys.executable).endswith('2'): + for k in ('f2py2','f2py2.6','f2py2.7',): + # if we found the f2py path, no need to look further + if which(k): + f2py_call = k + f2py_path = which(k) + break + # on Windows and other Linux using python/f2py else: + for k in ('f2py','f2py2.6','f2py2.7','f2py.py',): + # if we found the f2py path, no need to look further + if which(k): + f2py_call = k + f2py_path = which(k) + break + + try: print 'found f2py in:', f2py_path return f2py_call + # raise exception if f2py is not found, f2py_path variable will not exist + except NameError: + raise UserWarning, \ + 'Couldn\'t locate f2py. Should be part of NumPy installation.' # # 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': diff --git a/pywafo/src/wafo/source/mvn/build_all.py b/pywafo/src/wafo/source/mvn/build_all.py index 4f1d1b4..1b1228d 100644 --- a/pywafo/src/wafo/source/mvn/build_all.py +++ b/pywafo/src/wafo/source/mvn/build_all.py @@ -2,6 +2,7 @@ builds mvn.pyd """ import os +import sys def which(program): """ @@ -36,29 +37,33 @@ def which(program): def f2py_call_str(): # regardless of platform, try to figure out which f2py call is in the path # define possible options - f2py_call_list = ('f2py','f2py2.6','f2py2.7','f2py.py',) - no_f2py = True - for k in f2py_call_list: - # if the call command exists in the path, it will return the path as - # a string, otherwise it will return None - f2py_path = which(k) - no_f2py = not f2py_path - if no_f2py: - # didn't find the current call k, continue looking - pass - else: - # current call k is in the path - f2py_call = k - break - - # raise exception if f2py is not found - if no_f2py: - raise UserWarning, \ - 'Couldn\'t locate f2py. Should be part of NumPy installation.' + # on Arch Linux, python and f2py are the calls corresponding to python 3 + # and python2/f2py2 for python 2 + # other Linux versions might still use python/f2py for python 2 + if os.path.basename(sys.executable).endswith('2'): + for k in ('f2py2','f2py2.6','f2py2.7',): + # if we found the f2py path, no need to look further + if which(k): + f2py_call = k + f2py_path = which(k) + break + # on Windows and other Linux using python/f2py else: + for k in ('f2py','f2py2.6','f2py2.7','f2py.py',): + # if we found the f2py path, no need to look further + if which(k): + f2py_call = k + f2py_path = which(k) + break + + try: print 'found f2py in:', f2py_path return f2py_call + # raise exception if f2py is not found, f2py_path variable will not exist + except NameError: + raise UserWarning, \ + 'Couldn\'t locate f2py. Should be part of NumPy installation.' # # 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': diff --git a/pywafo/src/wafo/source/mvnprd/build_all.py b/pywafo/src/wafo/source/mvnprd/build_all.py index e9bac7b..bdc92b7 100644 --- a/pywafo/src/wafo/source/mvnprd/build_all.py +++ b/pywafo/src/wafo/source/mvnprd/build_all.py @@ -2,6 +2,7 @@ builds mvnprdmod.pyd """ import os +import sys def which(program): """ @@ -36,29 +37,33 @@ def which(program): def f2py_call_str(): # regardless of platform, try to figure out which f2py call is in the path # define possible options - f2py_call_list = ('f2py','f2py2.6','f2py2.7','f2py.py',) - no_f2py = True - for k in f2py_call_list: - # if the call command exists in the path, it will return the path as - # a string, otherwise it will return None - f2py_path = which(k) - no_f2py = not f2py_path - if no_f2py: - # didn't find the current call k, continue looking - pass - else: - # current call k is in the path - f2py_call = k - break - - # raise exception if f2py is not found - if no_f2py: - raise UserWarning, \ - 'Couldn\'t locate f2py. Should be part of NumPy installation.' + # on Arch Linux, python and f2py are the calls corresponding to python 3 + # and python2/f2py2 for python 2 + # other Linux versions might still use python/f2py for python 2 + if os.path.basename(sys.executable).endswith('2'): + for k in ('f2py2','f2py2.6','f2py2.7',): + # if we found the f2py path, no need to look further + if which(k): + f2py_call = k + f2py_path = which(k) + break + # on Windows and other Linux using python/f2py else: + for k in ('f2py','f2py2.6','f2py2.7','f2py.py',): + # if we found the f2py path, no need to look further + if which(k): + f2py_call = k + f2py_path = which(k) + break + + try: print 'found f2py in:', f2py_path return f2py_call + # raise exception if f2py is not found, f2py_path variable will not exist + except NameError: + raise UserWarning, \ + 'Couldn\'t locate f2py. Should be part of NumPy installation.' # # 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': diff --git a/pywafo/src/wafo/source/rind2007/build_all.py b/pywafo/src/wafo/source/rind2007/build_all.py index b40fae6..134088e 100644 --- a/pywafo/src/wafo/source/rind2007/build_all.py +++ b/pywafo/src/wafo/source/rind2007/build_all.py @@ -1,11 +1,12 @@ """ -Builds rindmod.pyd - -See also -http://www.scipy.org/Cookbook/CompilingExtensionsOnWindowsWithMinGW +Builds rindmod.pyd + +See also +http://www.scipy.org/Cookbook/CompilingExtensionsOnWindowsWithMinGW """ import os +import sys def which(program): """ @@ -39,29 +40,33 @@ def which(program): def f2py_call_str(): # regardless of platform, try to figure out which f2py call is in the path # define possible options - f2py_call_list = ('f2py','f2py2.6','f2py2.7','f2py.py',) - - no_f2py = True - for k in f2py_call_list: - # if the call command exists in the path, it will return the path as - # a string, otherwise it will return None - f2py_path = which(k) - no_f2py = not f2py_path - if no_f2py: - # didn't find the current call k, continue looking - pass - else: - # current call k is in the path - f2py_call = k - break - # raise exception if f2py is not found - if no_f2py: - raise UserWarning, \ - 'Couldn\'t locate f2py. Should be part of NumPy installation.' + # on Arch Linux, python and f2py are the calls corresponding to python 3 + # and python2/f2py2 for python 2 + # other Linux versions might still use python/f2py for python 2 + if os.path.basename(sys.executable).endswith('2'): + for k in ('f2py2','f2py2.6','f2py2.7',): + # if we found the f2py path, no need to look further + if which(k): + f2py_call = k + f2py_path = which(k) + break + # on Windows and other Linux using python/f2py else: + for k in ('f2py','f2py2.6','f2py2.7','f2py.py',): + # if we found the f2py path, no need to look further + if which(k): + f2py_call = k + f2py_path = which(k) + break + + try: print 'found f2py in:', f2py_path return f2py_call + # raise exception if f2py is not found, f2py_path variable will not exist + except NameError: + raise UserWarning, \ + 'Couldn\'t locate f2py. Should be part of NumPy installation.' # # 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':