|
18 | 18 | [INFO] op_uniffi_core - Calling unencrypted cc client test: ... |
19 | 19 | """ |
20 | 20 | import asyncio |
| 21 | +import importlib.util |
21 | 22 | import os |
| 23 | +import platform |
22 | 24 | import sys |
23 | 25 |
|
24 | 26 | # Ensure stderr is visible and unbuffered (helps on Linux and macOS) |
25 | 27 | sys.stderr.reconfigure(line_buffering=True) |
26 | 28 |
|
| 29 | + |
| 30 | +def _which_lib_path(): |
| 31 | + """Report which arch dir is used and the exact native library path (same logic as core.UniffiCore).""" |
| 32 | + machine = platform.machine().lower() |
| 33 | + if machine in ["x86_64", "amd64"]: |
| 34 | + arch = "x86_64" |
| 35 | + elif machine in ["aarch64", "arm64"]: |
| 36 | + arch = "aarch64" |
| 37 | + else: |
| 38 | + return None, None, f"unsupported: {machine}" |
| 39 | + ext = "dylib" if sys.platform == "darwin" else "so" |
| 40 | + spec = importlib.util.find_spec(f"onepassword.lib.{arch}.op_uniffi_core") |
| 41 | + if not spec or not spec.origin: |
| 42 | + return arch, None, "module not found" |
| 43 | + lib_dir = os.path.dirname(spec.origin) |
| 44 | + lib_path = os.path.join(lib_dir, f"libop_uniffi_core.{ext}") |
| 45 | + return arch, lib_path, None |
| 46 | + |
| 47 | + |
27 | 48 | async def main(): |
28 | 49 | token = os.getenv("OP_SERVICE_ACCOUNT_TOKEN") |
29 | 50 | if not token: |
30 | 51 | print("Set OP_SERVICE_ACCOUNT_TOKEN and re-run.", file=sys.stderr) |
31 | 52 | sys.exit(1) |
32 | 53 |
|
| 54 | + # Show which arch and path are used so you can confirm the right .so is loaded |
| 55 | + arch, lib_path, err = _which_lib_path() |
| 56 | + print(f"platform.machine() = {platform.machine()!r} -> using lib from: /{arch}/", file=sys.stderr) |
| 57 | + if lib_path: |
| 58 | + print(f"Native library path: {lib_path}", file=sys.stderr) |
| 59 | + print(f"File exists: {os.path.exists(lib_path)}", file=sys.stderr) |
| 60 | + if err: |
| 61 | + print(f"Note: {err}", file=sys.stderr) |
| 62 | + |
33 | 63 | from onepassword import Client |
34 | 64 |
|
35 | 65 | print("Calling Client.authenticate() (first call runs Rust init_logging_once + cc test)...", file=sys.stderr) |
|
0 commit comments