mirror of
https://github.com/mudler/LocalAI.git
synced 2024-12-19 04:37:53 +00:00
feat(binary): support extracted bundled libs on darwin (#2563)
When offering fallback libs, use the proper env var for darwin Note: this does not include the libraries itself, but only sets the proper env var for the libs to be picked up on darwin. Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
8f952d90b0
commit
06351cbbb4
@ -6,6 +6,7 @@ import (
|
|||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ResolvePath(dir string, paths ...string) string {
|
func ResolvePath(dir string, paths ...string) string {
|
||||||
@ -55,20 +56,25 @@ func ExtractFiles(content embed.FS, extractDir string) error {
|
|||||||
// we might use this mechanism to carry over e.g. Nvidia CUDA libraries
|
// we might use this mechanism to carry over e.g. Nvidia CUDA libraries
|
||||||
// from the embedded FS to the target directory
|
// from the embedded FS to the target directory
|
||||||
|
|
||||||
// Skip this if LOCALAI_SKIP_LD_LIBRARY_PATH is set
|
// Skip this if LOCALAI_SKIP_LIBRARY_PATH is set
|
||||||
if os.Getenv("LOCALAI_SKIP_LD_LIBRARY_PATH") != "" {
|
if os.Getenv("LOCALAI_SKIP_LIBRARY_PATH") != "" {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lpathVar := "LD_LIBRARY_PATH"
|
||||||
|
if runtime.GOOS == "darwin" {
|
||||||
|
lpathVar = "DYLD_FALLBACK_LIBRARY_PATH" // should it be DYLD_LIBRARY_PATH ?
|
||||||
|
}
|
||||||
|
|
||||||
for _, libDir := range []string{filepath.Join(extractDir, "backend_assets", "lib"), filepath.Join(extractDir, "lib")} {
|
for _, libDir := range []string{filepath.Join(extractDir, "backend_assets", "lib"), filepath.Join(extractDir, "lib")} {
|
||||||
if _, err := os.Stat(libDir); err == nil {
|
if _, err := os.Stat(libDir); err == nil {
|
||||||
ldLibraryPath := os.Getenv("LD_LIBRARY_PATH")
|
ldLibraryPath := os.Getenv(lpathVar)
|
||||||
if ldLibraryPath == "" {
|
if ldLibraryPath == "" {
|
||||||
ldLibraryPath = libDir
|
ldLibraryPath = libDir
|
||||||
} else {
|
} else {
|
||||||
ldLibraryPath = fmt.Sprintf("%s:%s", ldLibraryPath, libDir)
|
ldLibraryPath = fmt.Sprintf("%s:%s", ldLibraryPath, libDir)
|
||||||
}
|
}
|
||||||
os.Setenv("LD_LIBRARY_PATH", ldLibraryPath)
|
os.Setenv(lpathVar, ldLibraryPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user