1
0

libsecp256k1: add runtime support for 0.3.x

this replaces https://github.com/spesmilo/electrum/pull/8320

see f6bef03c0a/CHANGELOG.md

I am not yet sure how this will look like going forward, but unless there will
be lots of libsecp256k1 releases with ~invisible harmless ABI changes, I think
conceptually this is the right approach.
This commit is contained in:
SomberNight
2023-04-21 14:05:21 +00:00
parent 3cec6cdcfb
commit 784fc27cb9

View File

@@ -37,16 +37,23 @@ class LibModuleMissing(Exception): pass
def load_library():
# note: for a mapping between bitcoin-core/secp256k1 git tags and .so.V libtool version numbers,
# see https://github.com/bitcoin-core/secp256k1/pull/1055#issuecomment-1227505189
tested_libversions = [2, 1, 0, ] # try latest version first
libnames = []
if sys.platform == 'darwin':
libnames = ['libsecp256k1.1.dylib', 'libsecp256k1.0.dylib', ]
for v in tested_libversions:
libnames.append(f"libsecp256k1.{v}.dylib")
elif sys.platform in ('windows', 'win32'):
libnames = ['libsecp256k1-1.dll', 'libsecp256k1-0.dll', ]
for v in tested_libversions:
libnames.append(f"libsecp256k1-{v}.dll")
elif 'ANDROID_DATA' in os.environ:
libnames = ['libsecp256k1.so', ]
elif 'freebsd' in sys.platform:
libnames = ['libsecp256k1.so', ]
libnames = ['libsecp256k1.so', ] # don't care about version number. we built w/e is available.
else: # desktop Linux and similar
libnames = ['libsecp256k1.so.1', 'libsecp256k1.so.0', ]
for v in tested_libversions:
libnames.append(f"libsecp256k1.so.{v}")
# maybe we could fall back to trying "any" version? maybe guarded with an env var?
#libnames.append(f"libsecp256k1.so")
library_paths = []
for libname in libnames: # try local files in repo dir first
library_paths.append(os.path.join(os.path.dirname(__file__), libname))