99
1010import ctypes as ct # to call native
1111import ctypes .util as ctu
12- import pkg_resources # to determine the module's version
12+ import importlib . metadata # to determine module version at runtime
1313import platform # to learn the OS we're on
1414import sys
1515import warnings
@@ -24,16 +24,16 @@ def _load_shared_obj(name):
2424 paths = []
2525
2626 # search typical locations
27- paths += [ctu .find_library ("oqs" )]
28- paths += [ctu .find_library ("liboqs" )]
27+ paths += [ctu .find_library (name )]
28+ paths += [ctu .find_library ("lib" + name )]
2929 dll = ct .windll if platform .system () == "Windows" else ct .cdll
3030
3131 for path in paths :
3232 if path :
3333 lib = dll .LoadLibrary (path )
3434 return lib
3535
36- raise RuntimeError ("No liboqs shared libraries found" )
36+ raise RuntimeError ("No " + name + " shared libraries found" )
3737
3838
3939try :
@@ -63,9 +63,9 @@ def oqs_version():
6363def oqs_python_version ():
6464 """liboqs-python version string."""
6565 try :
66- result = pkg_resources . require ("liboqs-python" )[ 0 ]. version
67- except pkg_resources . DistributionNotFound :
68- warnings .warn ("Please install liboqs-python using setup.py " )
66+ result = importlib . metadata . version ("liboqs-python" )
67+ except importlib . metadata . PackageNotFoundError :
68+ warnings .warn ("Please install liboqs-python using pip install " )
6969 return None
7070 return result
7171
@@ -133,6 +133,7 @@ def __init__(self, alg_name, secret_key=None):
133133 get_enabled_KEM_mechanisms().
134134 :param secret_key: optional if generating by generate_keypair() later.
135135 """
136+ super ().__init__ ()
136137 self .alg_name = alg_name
137138 if alg_name not in _enabled_KEMs :
138139 # perhaps it's a supported but not enabled alg
@@ -214,7 +215,7 @@ def __repr__(self):
214215native ().OQS_KEM_alg_identifier .restype = ct .c_char_p
215216
216217
217- def is_KEM_enabled (alg_name ):
218+ def is_kem_enabled (alg_name ):
218219 """
219220 Returns True if the KEM algorithm is enabled.
220221
@@ -225,15 +226,15 @@ def is_KEM_enabled(alg_name):
225226
226227_KEM_alg_ids = [native ().OQS_KEM_alg_identifier (i ) for i in range (native ().OQS_KEM_alg_count ())]
227228_supported_KEMs = [i .decode () for i in _KEM_alg_ids ]
228- _enabled_KEMs = [i for i in _supported_KEMs if is_KEM_enabled (i )]
229+ _enabled_KEMs = [i for i in _supported_KEMs if is_kem_enabled (i )]
229230
230231
231- def get_enabled_KEM_mechanisms ():
232+ def get_enabled_kem_mechanisms ():
232233 """Returns the list of enabled KEM mechanisms."""
233234 return _enabled_KEMs
234235
235236
236- def get_supported_KEM_mechanisms ():
237+ def get_supported_kem_mechanisms ():
237238 """Returns the list of supported KEM mechanisms."""
238239 return _supported_KEMs
239240
@@ -273,6 +274,7 @@ def __init__(self, alg_name, secret_key=None):
273274 get_enabled_sig_mechanisms().
274275 :param secret_key: optional, if generated by generate_keypair().
275276 """
277+ super ().__init__ ()
276278 if alg_name not in _enabled_sigs :
277279 # perhaps it's a supported but not enabled alg
278280 if alg_name in _supported_sigs :
0 commit comments