From 464579078fab0b2219f96fec9385cb9ce95b170d Mon Sep 17 00:00:00 2001 From: Drew Short Date: Thu, 19 Sep 2019 20:56:49 -0500 Subject: [PATCH] Working on FFI examples --- FFI-tests/ffi_test.py | 10 ++++++++-- starter_file.rs | 4 ---- 2 files changed, 8 insertions(+), 6 deletions(-) delete mode 100644 starter_file.rs diff --git a/FFI-tests/ffi_test.py b/FFI-tests/ffi_test.py index 8fa353a..4a61968 100755 --- a/FFI-tests/ffi_test.py +++ b/FFI-tests/ffi_test.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 from ctypes import * +from sys import exit, platform import os large_image1_path = "../test_images/sample_01_large.jpg".encode(encoding="utf-8") @@ -33,12 +34,17 @@ print("starting ffi test") # Load the shared library lib = None -if os.name == 'nt': +if platform == 'win32': path = os.path.dirname(__file__) + "\\pihash.dll" print(path) lib = CDLL(path) -else: +elif platform == 'darwin': + lib = cdll.LoadLibrary("libpihash.dylib") +elif platform == 'linux' or platform == 'linux2': lib = cdll.LoadLibrary("libpihash.so") +else: + print('Unrecognized platform ', platform) + sys.exit(-1) class PIHashes(Structure): diff --git a/starter_file.rs b/starter_file.rs deleted file mode 100644 index 1aa3f5f..0000000 --- a/starter_file.rs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2015 Drew Short . -// -// Licensed under the MIT license. -// This file may not be copied, modified, or distributed except according to those terms.