File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3030#define _ATCA_VERSION_H
3131
3232// Version format yyyymmdd
33- #define ATCA_LIBRARY_VERSION_DATE "20210423 "
33+ #define ATCA_LIBRARY_VERSION_DATE "20210514 "
3434#define ATCA_LIBRARY_VERSION_MAJOR 3
3535#define ATCA_LIBRARY_VERSION_MINOR 3
3636#define ATCA_LIBRARY_VERSION_BUILD 1
Original file line number Diff line number Diff line change 2323
2424import os .path
2525import json
26+ import sys
2627from ctypes import *
2728from ctypes .util import find_library
2829from .exceptions import LibraryLoadError
@@ -69,6 +70,21 @@ def __str__(self):
6970 return str (self .value )
7071
7172
73+ def _force_local_library ():
74+ """
75+ In some environments loading seems to fail under all circumstances unless
76+ brute forcing it.
77+ """
78+ curr_path = os .path .dirname (__file__ )
79+
80+ if sys .platform .startswith ('win' ):
81+ return os .path .join (curr_path , "cryptoauth.dll" )
82+ elif sys .platform .startswith ('darwin' ):
83+ return os .path .join (curr_path , "libcryptoauth.dylib" )
84+ else :
85+ return os .path .join (curr_path , "libcryptoauth.so" )
86+
87+
7288def load_cryptoauthlib (lib = None ):
7389 """
7490 Load CryptoAauthLib into Python environment
@@ -80,7 +96,10 @@ def load_cryptoauthlib(lib=None):
8096 else :
8197 try :
8298 os .environ ['PATH' ] = os .path .dirname (__file__ ) + os .pathsep + os .environ ['PATH' ]
83- _CRYPTO_LIB = cdll .LoadLibrary (find_library ('cryptoauth' ))
99+ library_file = find_library ('cryptoauth' )
100+ if library_file is None :
101+ library_file = _force_local_library ()
102+ _CRYPTO_LIB = cdll .LoadLibrary (library_file )
84103 except :
85104 raise LibraryLoadError ('Unable to find cryptoauthlib. You may need to reinstall' )
86105
You can’t perform that action at this time.
0 commit comments