···1-From 208fe98f10c580a5a2fb6a8cfdd56de109073925 Mon Sep 17 00:00:00 2001
2-From: Frederik Rietdijk <fridh@fridh.nl>
3-Date: Sat, 17 Jul 2021 18:36:27 +0200
4-Subject: [PATCH] hardcode path to libgomp
5-6----
7- omp/__init__.py | 40 ++++------------------------------------
8- 1 file changed, 4 insertions(+), 36 deletions(-)
9-10diff --git a/omp/__init__.py b/omp/__init__.py
11-index bddae3063..9ba3678d8 100644
12--- a/omp/__init__.py
13+++ b/omp/__init__.py
14-@@ -69,43 +69,11 @@ class OpenMP(object):
01516 def init_not_msvc(self):
17- """ Find OpenMP library and try to load if using ctype interface. """
18-- # find_library() does not search automatically LD_LIBRARY_PATH
19-- paths = os.environ.get('LD_LIBRARY_PATH', '').split(':')
20-+ libgomp_path = "@gomp@"
21-22-- for libomp_name in self.get_libomp_names():
23-- if cxx is None or sys.platform == 'win32':
24-- # Note: Clang supports -print-file-name, but not yet for
25-- # clang-cl as of v12.0.0 (April '21)
26-- continue
000000000000000000000000000000027-
28-- cmd = [cxx, '-print-file-name=' + libomp_name]
29-- # the subprocess can fail in various ways in that case just give up
30-- try:
31-- path = os.path.dirname(check_output(cmd).decode().strip())
32-- if path:
33-- paths.append(path)
34-- except (OSError, CalledProcessError):
35-- pass
0036-
37-- # Try to load find libgomp shared library using loader search dirs
38-- libgomp_path = find_library("gomp")
000000039-
40-- # Try to use custom paths if lookup failed
41-- for path in paths:
42-- if libgomp_path:
43-- break
44-- path = path.strip()
45-- if os.path.isdir(path):
46-- libgomp_path = find_library(os.path.join(str(path), "libgomp"))
47-
48-- if not libgomp_path:
49-- raise ImportError("I can't find a shared library for libgomp,"
50-- " you may need to install it or adjust the "
51-- "LD_LIBRARY_PATH environment variable.")
52-- else:
53-- # Load the library (shouldn't fail with an absolute path right?)
54-- self.libomp = ctypes.CDLL(libgomp_path)
55-- self.version = 45
56-+ # Load the library (shouldn't fail with an absolute path right?)
57-+ self.libomp = ctypes.CDLL(libgomp_path)
58+ self.version = 45
5960 def __getattr__(self, name):
61 """
62---
63-2.32.0
64-
···0000000001diff --git a/omp/__init__.py b/omp/__init__.py
2+index 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']
78 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]))
0000074-
75++ self.libomp = ctypes.CDLL("@gomp@")
00000000076+ self.version = 45
7778 def __getattr__(self, name):
79 """
000