From 0523ba1905d9607962e45a04b5cd751859b3a503 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 8 May 2024 10:52:26 -0700 Subject: [PATCH] make build-time search for libucx insensitive to its internal layout --- setup.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index e5f4914d..da604598 100644 --- a/setup.py +++ b/setup.py @@ -22,10 +22,27 @@ # not where 'libucx' is going to be installed at build time when using # build isolation try: + import glob + import libucx - libucx_libdir = os.path.join(os.path.dirname(libucx.__file__), "lib") - library_dirs.append(libucx_libdir) + # find 'libucx' + module_dir = os.path.dirname(libucx.__file__) + + # find where it stores files like 'libucm.so.0' + libs = glob.glob(f"{module_dir}/**/lib*.so*", recursive=True) + + # deduplicate those library paths + lib_dirs = {os.path.dirname(f) for f in libs} + if not lib_dirs: + raise RuntimeError( + f"Did not find shared libraries in 'libucx' install location ({module_dir})" + ) + + # add all the places 'libucx' stores libraries to that paths + # considered by the linker when compiling extensions + library_dirs.extend(lib_dirs) + except ImportError: pass