Skip to content

Commit 64c338a

Browse files
committed
logging to see what's going on in linux
1 parent efd4988 commit 64c338a

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

example/verify_internal.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,48 @@
1818
[INFO] op_uniffi_core - Calling unencrypted cc client test: ...
1919
"""
2020
import asyncio
21+
import importlib.util
2122
import os
23+
import platform
2224
import sys
2325

2426
# Ensure stderr is visible and unbuffered (helps on Linux and macOS)
2527
sys.stderr.reconfigure(line_buffering=True)
2628

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+
2748
async def main():
2849
token = os.getenv("OP_SERVICE_ACCOUNT_TOKEN")
2950
if not token:
3051
print("Set OP_SERVICE_ACCOUNT_TOKEN and re-run.", file=sys.stderr)
3152
sys.exit(1)
3253

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+
3363
from onepassword import Client
3464

3565
print("Calling Client.authenticate() (first call runs Rust init_logging_once + cc test)...", file=sys.stderr)

0 commit comments

Comments
 (0)