From d3d35a3b60b4b41d905821ea4f38b6fcf14ca086 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Fri, 5 Jan 2018 10:06:03 +0100 Subject: Handle library names for all OSes Signed-off-by: Szczepan Zalega --- python_bindings_example.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/python_bindings_example.py b/python_bindings_example.py index 7bb806c..7911846 100755 --- a/python_bindings_example.py +++ b/python_bindings_example.py @@ -41,16 +41,23 @@ def get_library(): C = None import os, sys path_build = os.path.join(".", "build") - paths = [ os.path.join(path_build,"libnitrokey-log.so"), - os.path.join(path_build,"libnitrokey.so")] + paths = [ + os.environ.get('LIBNK_PATH', None), + os.path.join(path_build,"libnitrokey.so"), + os.path.join(path_build,"libnitrokey.dylib"), + os.path.join(path_build,"libnitrokey.dll"), + os.path.join(path_build,"nitrokey.dll"), + ] for p in paths: - print p + if not p: continue + print("Trying " +p) + p = os.path.abspath(p) if os.path.exists(p): + print("Found: "+p) C = ffi.dlopen(p) break else: print("File does not exist: " + p) - print("Trying another") if not C: print("No library file found") sys.exit(1) -- cgit v1.2.3