Find the GraphLite shared library
()
| 101 | |
| 102 | |
| 103 | def _find_library() -> str: |
| 104 | """Find the GraphLite shared library""" |
| 105 | system = platform.system() |
| 106 | |
| 107 | # Determine library name based on platform |
| 108 | if system == "Darwin": # macOS |
| 109 | lib_name = "libgraphlite_ffi.dylib" |
| 110 | elif system == "Windows": |
| 111 | lib_name = "graphlite_ffi.dll" |
| 112 | else: # Linux and others |
| 113 | lib_name = "libgraphlite_ffi.so" |
| 114 | |
| 115 | # Search paths |
| 116 | search_paths = [ |
| 117 | # Relative to this file (development) |
| 118 | Path(__file__).parent.parent.parent.parent / "target" / "release" / lib_name, |
| 119 | Path(__file__).parent.parent.parent.parent / "target" / "debug" / lib_name, |
| 120 | # Installed location |
| 121 | Path("/usr/local/lib") / lib_name, |
| 122 | Path("/usr/lib") / lib_name, |
| 123 | # Current directory |
| 124 | Path.cwd() / lib_name, |
| 125 | ] |
| 126 | |
| 127 | for path in search_paths: |
| 128 | if path.exists(): |
| 129 | return str(path) |
| 130 | |
| 131 | raise FileNotFoundError( |
| 132 | f"Could not find GraphLite library ({lib_name}). " |
| 133 | f"Please build the FFI library first: cargo build --release -p graphlite-ffi" |
| 134 | ) |
| 135 | |
| 136 | |
| 137 | # Load the library |