Description: Patch for boost numpy support in Debian
 Need to find appropriate boost_python library.
 Be careful not to overmatch; eg. there may be multiple such as:
    libboost_numpy38.so, libboost_numpy39.so
Author: Alastair McKinstry <mckinstry@debian.org>
Last-Updated: 2020-12-10
Forwarded: no


Index: python-escript-5.6/site_scons/dependencies.py
===================================================================
--- python-escript-5.6.orig/site_scons/dependencies.py
+++ python-escript-5.6/site_scons/dependencies.py
@@ -95,7 +95,7 @@ def get_external_python_sympy(env,bin):
     tmp2 = ver[1]
     if tmp2 == '.':
         tmp2 = ver[2]
-        
+    
     if int(tmp1) == 0 and int(tmp2) < 7:
         env['sympy'] = False
         env['warnings'].append("sympy version is too old.")
@@ -303,57 +303,16 @@ def checkBoost(env):
     if boostversion >= 106300 and env['disable_boost_numpy'] is False:
         try:
             boost_numpy_inc_path,boost_numpy_lib_path=findLibWithHeader(env, env['boost_libs'], 'boost/python/numpy.hpp', env['boost_prefix'], lang='c++')
-
             # Locate the boost numpy files
+            import sys
             if env['IS_WINDOWS']:
-                raise Exception # TODO: fix boost numpy dll ex/import compile errors
-                import sys
                 for l in os.listdir(env['boost_prefix'] + '\\lib'):
                     if l.startswith('boost_numpy{}{}'.format(sys.version_info.major,sys.version_info.minor)):
                         libname = os.path.splitext(l)[0]
             else:
-                p = subprocess.Popen(["ld","--verbose"], stdout=subprocess.PIPE)
-                out,err = p.communicate()
-                spath = [x[13:-3] for x in out.split() if b'SEARCH_DIR' in x]
-                spath.append(boost_lib_path)
-                p2name = ''
-                p3name = ''
-                for name in spath:
-                    try:
-                        l=os.listdir(name)
-
-                        import sys
-                        if sys.version_info[0] == 3:
-                            string_type = str
-                        else:
-                            string_type = basestring
-
-                        p2res = ''
-                        p3res = ''
-                        for x in l:
-                            if isinstance(x,string_type):
-                                if x.startswith('libboost_numpy-py') and x.endswith('.so'):
-                                    p2res = x
-                                if x.startswith('libboost_numpy-py3') and x.endswith('.so'):
-                                    p3res = x
-                            else:
-                                if x.startswith(b'libboost_numpy-py') and x.endswith(b'.so'):
-                                    p2res = x
-                                if x.startswith(b'libboost_numpy-py3') and x.endswith(b'.so'):
-                                    p3res = x
-
-                        if len(p2name)==0 and len(p2res)>0:
-                            p2name=p2res[-1]
-                        if len(p3name)==0 and len(p3res)>0:
-                            p3name=p3res[-1]
-                    except OSError:
-                        pass
-
-                # Pick the right one
-                if int(env['python_version'][0]) == 2:
-                    libname = p2name[3:-3]
-                else:
-                    libname = p3name[3:-3]
+                for l in os.listdir(env['boost_prefix'][1]):
+                    if l == f'libboost_numpy{sys.version_info.major}{sys.version_info.minor}.so':
+                        libname = l
 
             # If found, add the necessary information to env
             if len(libname) > 0:
