mirror of
https://github.com/Z3Prover/z3
synced 2025-06-03 21:01:22 +00:00
change share library search in Z3Py
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
5060b617ab
commit
ec907a4705
1 changed files with 15 additions and 19 deletions
|
@ -58,28 +58,24 @@ core_py.write('import ctypes\n')
|
||||||
core_py.write('from z3types import *\n')
|
core_py.write('from z3types import *\n')
|
||||||
core_py.write('from z3consts import *\n')
|
core_py.write('from z3consts import *\n')
|
||||||
core_py.write("""
|
core_py.write("""
|
||||||
def _find_lib():
|
|
||||||
_dir = os.path.dirname(os.path.abspath(__file__))
|
|
||||||
libs = ['libz3.dll', 'libz3.so', 'libz3.dylib']
|
|
||||||
if sys.maxsize > 2**32:
|
|
||||||
locs = [_dir, '%s%s..%sx64%sexternal' % (_dir, os.sep, os.sep, os.sep), '%s%s..%sbin%sexternal' % (_dir, os.sep, os.sep, os.sep)]
|
|
||||||
else:
|
|
||||||
locs = [_dir, '%s%s..%sexternal' % (_dir, os.sep, os.sep), '%s%s..%sbin%sexternal' % (_dir, os.sep, os.sep, os.sep)]
|
|
||||||
for loc in locs:
|
|
||||||
for lib in libs:
|
|
||||||
f = '%s%s%s' % (loc, os.sep, lib)
|
|
||||||
if os.path.exists(f):
|
|
||||||
return f
|
|
||||||
return None
|
|
||||||
|
|
||||||
_lib = None
|
_lib = None
|
||||||
def lib():
|
def lib():
|
||||||
|
global _lib
|
||||||
if _lib == None:
|
if _lib == None:
|
||||||
l = _find_lib()
|
_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
if l == None:
|
for ext in ['dll', 'so', 'dylib']:
|
||||||
raise Z3Exception("init(Z3_LIBRARY_PATH) must be invoked before using Z3-python")
|
try:
|
||||||
init(l)
|
init('libz3.%s' % ext)
|
||||||
assert _lib != None
|
break
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
init('%s%slibz3.%s' % (_dir, ext))
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
if _lib == None:
|
||||||
|
raise Z3Exception("init(Z3_LIBRARY_PATH) must be invoked before using Z3-python")
|
||||||
return _lib
|
return _lib
|
||||||
|
|
||||||
def init(PATH):
|
def init(PATH):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue