commit 23ba130187fbc8abc76d42b97ccb937d518f4050 parent 9869ada1b8523222e5ea50034da5e838ff82aae0 Author: nolash <dev@holbrook.no> Date: Tue, 13 Apr 2021 10:44:58 +0200 Rename project Diffstat:
A | pylibrlp/__init__.py | | | 30 | ++++++++++++++++++++++++++++++ |
1 file changed, 30 insertions(+), 0 deletions(-)
diff --git a/pylibrlp/__init__.py b/pylibrlp/__init__.py @@ -0,0 +1,30 @@ +# standard imports +import sys +import re +import os +import ctypes +import ctypes.util + + +LIBRLP_RLP_MAX_LIST_DEPTH = 1024 + + +__path_librlp = ctypes.util.find_library('rlp') + + +if __path_librlp == None: + v = sys.version_info + re_so = r'^rlp.cpython-' + str(v[0]) + str(v[1]) + '.*\.so$' + script_dir = os.path.dirname(__file__) + root_dir = os.path.join(script_dir, '..') + for f in os.listdir(root_dir): + if re.match(re_so, f): + __path_librlp = os.path.join(root_dir, f) + break + +if __path_librlp == None: + raise ImportError('missing librlp shared library') + +librlp = ctypes.CDLL(__path_librlp) + +from .encoder import RLPEncoder