@@ -96,15 +96,24 @@ def get_ld_library_path(prefix: Path) -> str:
9696 # <prefix>/lib/* or sometimes just <prefix>/lib
9797 # this function returns the path to the ld library path
9898
99- # first, check if the ld library path exists at <prefix>/lib/*
100- ld_library_paths = list (prefix .glob ("lib/*" ))
99+ # On macOS ARM64, libraries are typically installed directly to <prefix>/lib
100+ # On macOS Intel, they might be in <prefix>/lib/x86_64-darwin
101+ # On Linux, they might be in <prefix>/lib/x86_64-linux-gnu or similar
102+
103+ # First, check for architecture-specific subdirectories in <prefix>/lib/*
104+ # Filter to only include directories, not files
105+ ld_library_paths = [p for p in prefix .glob ("lib/*" ) if p .is_dir ()]
101106 if len (ld_library_paths ) == 1 :
102107 return ld_library_paths [0 ].absolute ().as_posix ()
103108
104- # if the ld library path does not exist at <prefix>/lib/*,
105- # return <prefix>/lib
109+ # If no single subdirectory, check if libraries exist directly in <prefix>/lib
106110 ld_library_path = prefix / "lib"
107111 if ld_library_path .exists ():
112+ # Check if there are actual library files here
113+ lib_files = list (ld_library_path .glob ("*.dylib" )) + list (ld_library_path .glob ("*.so*" ))
114+ if lib_files :
115+ return ld_library_path .absolute ().as_posix ()
116+ # If lib/ exists but has no libraries, return it anyway as fallback
108117 return ld_library_path .absolute ().as_posix ()
109118 return ""
110119
0 commit comments