77import tempfile
88import urllib .request
99import json
10- import tarfile
10+ import zipfile
1111
1212def is_command_available (cmd ):
1313 return shutil .which (cmd ) is not None
@@ -42,25 +42,25 @@ def install_z3_latest():
4242 with urllib .request .urlopen (api_url ) as response :
4343 data = json .loads (response .read ().decode ())
4444
45- # Look for a Linux x64 tarball
45+ # Look for a Linux x64-glibc zip archive
4646 assets = data .get ("assets" , [])
47- tarball_url = None
47+ zip_url = None
4848 for asset in assets :
49- if "x64-glibc" in asset ["name" ] and asset ["name" ].endswith (".tar.gz " ):
50- tarball_url = asset ["browser_download_url" ]
49+ if "x64-glibc" in asset ["name" ] and asset ["name" ].endswith (".zip " ):
50+ zip_url = asset ["browser_download_url" ]
5151 break
5252
53- if not tarball_url :
54- raise Exception ("Could not find a suitable Linux x64 Z3 tarball ." )
53+ if not zip_url :
54+ raise Exception ("Could not find a suitable Linux x64-glibc Z3 zip archive ." )
5555
56- print (f"Downloading: { tarball_url } " )
56+ print (f"Downloading: { zip_url } " )
5757 with tempfile .TemporaryDirectory () as tmpdir :
58- tar_path = os .path .join (tmpdir , "z3.tar.gz " )
59- urllib .request .urlretrieve (tarball_url , tar_path )
58+ zip_path = os .path .join (tmpdir , "z3.zip " )
59+ urllib .request .urlretrieve (zip_url , zip_path )
6060
61- print ("Extracting tarball ..." )
62- with tarfile . open ( tar_path , "r:gz " ) as tar :
63- tar .extractall (path = tmpdir )
61+ print ("Extracting zip archive ..." )
62+ with zipfile . ZipFile ( zip_path , "r" ) as zip_ref :
63+ zip_ref .extractall (tmpdir )
6464
6565 # Find the extracted directory
6666 extracted_dirs = [d for d in os .listdir (tmpdir ) if os .path .isdir (os .path .join (tmpdir , d ))]
@@ -69,11 +69,12 @@ def install_z3_latest():
6969 z3_dir = os .path .join (tmpdir , extracted_dirs [0 ])
7070
7171 include_dir = os .path .join (z3_dir , "include" )
72- lib_dir = os .path .join (z3_dir , "bin" ) # Z3 often puts .so files in ' bin'
72+ lib_dir = os .path .join (z3_dir , "bin" ) # Z3 typically puts .so in bin
7373
7474 # Install to /usr/local
7575 print ("Installing headers and shared libraries to /usr/local..." )
76- subprocess .run (['cp' , '-r' , include_dir , '/usr/local/include/z3' ], check = True )
76+ subprocess .run (['mkdir' , '-p' , '/usr/local/include/z3' ], check = True )
77+ subprocess .run (['cp' , '-r' , include_dir + '/' , '/usr/local/include/z3' ], check = True )
7778 subprocess .run (['cp' , os .path .join (lib_dir , 'libz3.so' ), '/usr/local/lib/' ], check = True )
7879
7980 # Refresh the linker cache
0 commit comments