at master 3.2 kB view raw
1diff --git a/omp/__init__.py b/omp/__init__.py 2index 3801d1c8c..a93a74d6f 100644 3--- a/omp/__init__.py 4+++ b/omp/__init__.py 5@@ -48,72 +48,8 @@ class OpenMP(object): 6 return ['omp', 'gomp', 'iomp5'] 7 8 def init_not_msvc(self): 9- """ Find OpenMP library and try to load if using ctype interface. """ 10- # find_library() does not automatically search LD_LIBRARY_PATH 11- # until Python 3.6+, so we explicitly add it. 12- # LD_LIBRARY_PATH is used on Linux, while macOS uses DYLD_LIBRARY_PATH 13- # and DYLD_FALLBACK_LIBRARY_PATH. 14- env_vars = [] 15- if sys.platform == 'darwin': 16- env_vars = ['DYLD_LIBRARY_PATH', 'DYLD_FALLBACK_LIBRARY_PATH'] 17- else: 18- env_vars = ['LD_LIBRARY_PATH'] 19- 20- paths = [] 21- for env_var in env_vars: 22- env_paths = os.environ.get(env_var, '') 23- if env_paths: 24- paths.extend(env_paths.split(os.pathsep)) 25- 26- 27- libomp_names = self.get_libomp_names() 28- 29- if cxx is not None: 30- for libomp_name in libomp_names: 31- cmd = [cxx, 32- '-print-file-name=lib{}{}'.format( 33- libomp_name, 34- get_shared_lib_extension())] 35- # The subprocess can fail in various ways, including because it 36- # doesn't support '-print-file-name'. In that case just give up. 37- try: 38- output = check_output(cmd, 39- stderr=DEVNULL) 40- path = os.path.dirname(output.decode().strip()) 41- if path: 42- paths.append(path) 43- except (OSError, CalledProcessError): 44- pass 45- 46- 47- for libomp_name in libomp_names: 48- # Try to load find libomp shared library using loader search dirs 49- libomp_path = find_library(libomp_name) 50- 51- # Try to use custom paths if lookup failed 52- if not libomp_path: 53- for path in paths: 54- candidate_path = os.path.join( 55- path, 56- 'lib{}{}'.format(libomp_name, 57- get_shared_lib_extension())) 58- if os.path.isfile(candidate_path): 59- libomp_path = candidate_path 60- break 61- 62- # Load the library 63- if libomp_path: 64- try: 65- self.libomp = ctypes.CDLL(libomp_path) 66- except OSError: 67- raise ImportError("found openMP library '{}' but couldn't load it. " 68- "This may happen if you are cross-compiling.".format(libomp_path)) 69- self.version = 45 70- return 71- 72- raise ImportError("I can't find a shared library for libomp, you may need to install it " 73- "or adjust the {} environment variable.".format(env_vars[0])) 74- 75+ self.libomp = ctypes.CDLL("@gomp@") 76+ self.version = 45 77 78 def __getattr__(self, name): 79 """