From 4979b744558aaa1380e9291d83da384b2c5c6384 Mon Sep 17 00:00:00 2001 From: Meow Date: Thu, 4 Dec 2025 21:08:51 -0500 Subject: [PATCH] feat: custom shared library path --- src/onepassword/client.py | 6 ++++-- src/onepassword/desktop_core.py | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/onepassword/client.py b/src/onepassword/client.py index 290cca9..21746e5 100644 --- a/src/onepassword/client.py +++ b/src/onepassword/client.py @@ -19,7 +19,9 @@ class Client: @classmethod async def authenticate( - cls, auth: str | DesktopAuth, integration_name: str, integration_version: str + cls, auth: str | DesktopAuth, + integration_name: str, integration_version: str, + shared_library_path: str = "" ) -> Client: config = new_default_config( auth=auth, @@ -28,7 +30,7 @@ async def authenticate( ) if isinstance(auth, DesktopAuth): - core = DesktopCore(auth.account_name) + core = DesktopCore(auth.account_name, shared_library_path) else: core = UniffiCore() diff --git a/src/onepassword/desktop_core.py b/src/onepassword/desktop_core.py index 6c8fca7..20ff990 100644 --- a/src/onepassword/desktop_core.py +++ b/src/onepassword/desktop_core.py @@ -8,7 +8,7 @@ from onepassword.errors import raise_typed_exception -def find_1password_lib_path(): +def find_1password_lib_path(custom_location: str = ""): os_name = platform.system() # Define paths based on OS @@ -32,6 +32,9 @@ def find_1password_lib_path(): ] else: raise OSError(f"Unsupported operating system: {os_name}") + + if isinstance(custom_location, str) and len(custom_location) > 0: + locations.insert(0, custom_location) for lib_path in locations: if os.path.exists(lib_path): @@ -40,9 +43,9 @@ def find_1password_lib_path(): raise FileNotFoundError("1Password desktop application not found") class DesktopCore: - def __init__(self, account_name: str): + def __init__(self, account_name: str, library_path: str = ""): # Determine the path to the desktop app. - path = find_1password_lib_path() + path = find_1password_lib_path(library_path) self.lib = ctypes.CDLL(path) self.account_name = account_name