···11-From 208fe98f10c580a5a2fb6a8cfdd56de109073925 Mon Sep 17 00:00:00 2001
22-From: Frederik Rietdijk <fridh@fridh.nl>
33-Date: Sat, 17 Jul 2021 18:36:27 +0200
44-Subject: [PATCH] hardcode path to libgomp
55-66----
77- omp/__init__.py | 40 ++++------------------------------------
88- 1 file changed, 4 insertions(+), 36 deletions(-)
99-101diff --git a/omp/__init__.py b/omp/__init__.py
1111-index bddae3063..9ba3678d8 100644
22+index 3801d1c8c..a93a74d6f 100644
123--- a/omp/__init__.py
134+++ b/omp/__init__.py
1414-@@ -69,43 +69,11 @@ class OpenMP(object):
55+@@ -48,72 +48,8 @@ class OpenMP(object):
66+ return ['omp', 'gomp', 'iomp5']
157168 def init_not_msvc(self):
1717- """ Find OpenMP library and try to load if using ctype interface. """
1818-- # find_library() does not search automatically LD_LIBRARY_PATH
1919-- paths = os.environ.get('LD_LIBRARY_PATH', '').split(':')
2020-+ libgomp_path = "@gomp@"
2121-2222-- for libomp_name in self.get_libomp_names():
2323-- if cxx is None or sys.platform == 'win32':
2424-- # Note: Clang supports -print-file-name, but not yet for
2525-- # clang-cl as of v12.0.0 (April '21)
2626-- continue
99+- """ Find OpenMP library and try to load if using ctype interface. """
1010+- # find_library() does not automatically search LD_LIBRARY_PATH
1111+- # until Python 3.6+, so we explicitly add it.
1212+- # LD_LIBRARY_PATH is used on Linux, while macOS uses DYLD_LIBRARY_PATH
1313+- # and DYLD_FALLBACK_LIBRARY_PATH.
1414+- env_vars = []
1515+- if sys.platform == 'darwin':
1616+- env_vars = ['DYLD_LIBRARY_PATH', 'DYLD_FALLBACK_LIBRARY_PATH']
1717+- else:
1818+- env_vars = ['LD_LIBRARY_PATH']
1919+-
2020+- paths = []
2121+- for env_var in env_vars:
2222+- env_paths = os.environ.get(env_var, '')
2323+- if env_paths:
2424+- paths.extend(env_paths.split(os.pathsep))
2525+-
2626+-
2727+- libomp_names = self.get_libomp_names()
2828+-
2929+- if cxx is not None:
3030+- for libomp_name in libomp_names:
3131+- cmd = [cxx,
3232+- '-print-file-name=lib{}{}'.format(
3333+- libomp_name,
3434+- get_shared_lib_extension())]
3535+- # The subprocess can fail in various ways, including because it
3636+- # doesn't support '-print-file-name'. In that case just give up.
3737+- try:
3838+- output = check_output(cmd,
3939+- stderr=DEVNULL)
4040+- path = os.path.dirname(output.decode().strip())
4141+- if path:
4242+- paths.append(path)
4343+- except (OSError, CalledProcessError):
4444+- pass
4545+-
4646+-
4747+- for libomp_name in libomp_names:
4848+- # Try to load find libomp shared library using loader search dirs
4949+- libomp_path = find_library(libomp_name)
2750-
2828-- cmd = [cxx, '-print-file-name=' + libomp_name]
2929-- # the subprocess can fail in various ways in that case just give up
3030-- try:
3131-- path = os.path.dirname(check_output(cmd).decode().strip())
3232-- if path:
3333-- paths.append(path)
3434-- except (OSError, CalledProcessError):
3535-- pass
5151+- # Try to use custom paths if lookup failed
5252+- if not libomp_path:
5353+- for path in paths:
5454+- candidate_path = os.path.join(
5555+- path,
5656+- 'lib{}{}'.format(libomp_name,
5757+- get_shared_lib_extension()))
5858+- if os.path.isfile(candidate_path):
5959+- libomp_path = candidate_path
6060+- break
3661-
3737-- # Try to load find libgomp shared library using loader search dirs
3838-- libgomp_path = find_library("gomp")
6262+- # Load the library
6363+- if libomp_path:
6464+- try:
6565+- self.libomp = ctypes.CDLL(libomp_path)
6666+- except OSError:
6767+- raise ImportError("found openMP library '{}' but couldn't load it. "
6868+- "This may happen if you are cross-compiling.".format(libomp_path))
6969+- self.version = 45
7070+- return
3971-
4040-- # Try to use custom paths if lookup failed
4141-- for path in paths:
4242-- if libgomp_path:
4343-- break
4444-- path = path.strip()
4545-- if os.path.isdir(path):
4646-- libgomp_path = find_library(os.path.join(str(path), "libgomp"))
7272+- raise ImportError("I can't find a shared library for libomp, you may need to install it "
7373+- "or adjust the {} environment variable.".format(env_vars[0]))
4774-
4848-- if not libgomp_path:
4949-- raise ImportError("I can't find a shared library for libgomp,"
5050-- " you may need to install it or adjust the "
5151-- "LD_LIBRARY_PATH environment variable.")
5252-- else:
5353-- # Load the library (shouldn't fail with an absolute path right?)
5454-- self.libomp = ctypes.CDLL(libgomp_path)
5555-- self.version = 45
5656-+ # Load the library (shouldn't fail with an absolute path right?)
5757-+ self.libomp = ctypes.CDLL(libgomp_path)
7575++ self.libomp = ctypes.CDLL("@gomp@")
5876+ self.version = 45
59776078 def __getattr__(self, name):
6179 """
6262---
6363-2.32.0
6464-