MCPcopy
hub / github.com/dnhkng/GLaDOS / _create_ld_so_cache

Method _create_ld_so_cache

glados/whisper_cpp_wrapper.py:729–797  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

727 pass
728
729 def _create_ld_so_cache(self):
730 # Recreate search path followed by ld.so. This is going to be
731 # slow to build, and incorrect (ld.so uses ld.so.cache, which may
732 # not be up-to-date). Used only as fallback for distros without
733 # /sbin/ldconfig.
734 #
735 # We assume the DT_RPATH and DT_RUNPATH binary sections are omitted.
736
737 directories = self._Directories()
738 for name in (
739 "LD_LIBRARY_PATH",
740 "SHLIB_PATH", # HP-UX
741 "LIBPATH", # OS/2, AIX
742 "LIBRARY_PATH", # BE/OS
743 ):
744 if name in os.environ:
745 directories.extend(os.environ[name].split(os.pathsep))
746
747 self._get_ld_so_conf_dirs("/etc/ld.so.conf", directories)
748
749 bitage = platform.architecture()[0]
750
751 unix_lib_dirs_list = []
752 if bitage.startswith("64"):
753 # prefer 64 bit if that is our arch
754 unix_lib_dirs_list += ["/lib64", "/usr/lib64"]
755
756 # must include standard libs, since those paths are also used by 64 bit
757 # installs
758 unix_lib_dirs_list += ["/lib", "/usr/lib"]
759 if sys.platform.startswith("linux"):
760 # Try and support multiarch work in Ubuntu
761 # https://wiki.ubuntu.com/MultiarchSpec
762 if bitage.startswith("32"):
763 # Assume Intel/AMD x86 compat
764 unix_lib_dirs_list += ["/lib/i386-linux-gnu", "/usr/lib/i386-linux-gnu"]
765 elif bitage.startswith("64"):
766 # Assume Intel/AMD x86 compatible
767 unix_lib_dirs_list += [
768 "/lib/x86_64-linux-gnu",
769 "/usr/lib/x86_64-linux-gnu",
770 ]
771 else:
772 # guess...
773 unix_lib_dirs_list += glob.glob("/lib/*linux-gnu")
774 directories.extend(unix_lib_dirs_list)
775
776 cache = {}
777 lib_re = re.compile(r"lib(.*)\.s[ol]")
778 # ext_re = re.compile(r"\.s[ol]$")
779 for our_dir in directories.ordered():
780 try:
781 for path in glob.glob("%s/*.s[ol]*" % our_dir):
782 file = os.path.basename(path)
783
784 # Index by filename
785 cache_i = cache.setdefault(file, set())
786 cache_i.add(path)

Callers 1

getplatformpathsMethod · 0.95

Calls 6

_get_ld_so_conf_dirsMethod · 0.95
extendMethod · 0.80
splitMethod · 0.80
startswithMethod · 0.80
orderedMethod · 0.80
addMethod · 0.80

Tested by

no test coverage detected