|
1 | 1 | import ctypes |
2 | 2 | import json |
3 | 3 | import os |
| 4 | +import platform |
4 | 5 | import base64 |
| 6 | +from pathlib import Path |
5 | 7 | from ctypes import c_uint8, c_size_t, c_int32, POINTER, byref, c_void_p |
6 | 8 | from .core import UniffiCore |
7 | 9 | from onepassword.errors import raise_typed_exception |
8 | 10 |
|
9 | 11 |
|
10 | 12 | def find_1password_lib_path(): |
11 | | - locations = [ |
12 | | - "/Users/andititu/core/target/debug/libop_sdk_ipc_client.dylib" |
13 | | - ] |
| 13 | + os_name = platform.system() |
| 14 | + |
| 15 | + # Define paths based on OS |
| 16 | + if os_name == "Darwin": # macOS |
| 17 | + locations = [ |
| 18 | + "/Applications/1Password.app/Contents/Frameworks/libop_sdk_ipc_client.dylib", |
| 19 | + str(Path.home() / "Applications/1Password.app/Contents/Frameworks/libop_sdk_ipc_client.dylib"), |
| 20 | + ] |
| 21 | + elif os_name == "Linux": |
| 22 | + locations = [ |
| 23 | + "/usr/bin/1password/libop_sdk_ipc_client.so", |
| 24 | + "/opt/1password/libop_sdk_ipc_client.so", |
| 25 | + "/snap/bin/1password/libop_sdk_ipc_client.so", |
| 26 | + ] |
| 27 | + elif os_name == "Windows": |
| 28 | + locations = [ |
| 29 | + r"C:\Program Files\1Password\op_sdk_ipc_client.dll", |
| 30 | + r"C:\Program Files (x86)\1Password\op_sdk_ipc_client.dll", |
| 31 | + str(Path.home() / r"AppData\Local\1Password\op_sdk_ipc_client.dll"), |
| 32 | + ] |
| 33 | + else: |
| 34 | + raise OSError(f"Unsupported operating system: {os_name}") |
14 | 35 |
|
15 | 36 | for lib_path in locations: |
16 | 37 | if os.path.exists(lib_path): |
|
0 commit comments