@@ -80,25 +80,28 @@ def _download_file(url, path, showprogress=True):
8080 exit (1 )
8181
8282def _setup (download_dir , platform , showprogress = False ):
83- print ('installing stackql...' )
84- try :
85- binary_name = _get_binary_name (platform )
86- url = _get_url ()
87- print ("downloading latest version of stackql from %s to %s" % (url , download_dir ))
88- archive_file_name = os .path .join (download_dir , os .path .basename (url ))
89- _download_file (url , archive_file_name , showprogress )
90- if platform == 'Darwin' :
91- unpacked_file_name = os .path .join (download_dir , 'stackql' )
92- command = 'pkgutil --expand-full {} {}' .format (archive_file_name , unpacked_file_name )
93- os .system (command )
94- else :
95- with zipfile .ZipFile (archive_file_name , 'r' ) as zip_ref :
96- zip_ref .extractall (download_dir )
97-
98- os .chmod (os .path .join (download_dir , binary_name ), 0o755 )
99- except Exception as e :
100- print ("ERROR: [_setup] %s" % (str (e )))
101- exit (1 )
83+ try :
84+ print ('installing stackql...' )
85+ binary_name = _get_binary_name (platform )
86+ url = _get_url ()
87+ print ("downloading latest version of stackql from %s to %s" % (url , download_dir ))
88+ archive_file_name = os .path .join (download_dir , os .path .basename (url ))
89+ _download_file (url , archive_file_name , showprogress )
90+ # if Platform is starting with Darwin, then it is a MacOS
91+ if platform .startswith ('Darwin' ):
92+ unpacked_file_name = os .path .join (download_dir , 'stackql' )
93+ command = 'pkgutil --expand-full {} {}' .format (archive_file_name , unpacked_file_name )
94+ # if there are files in unpacked_file_name, then remove them
95+ if os .path .exists (unpacked_file_name ):
96+ os .system ('rm -rf {}' .format (unpacked_file_name ))
97+ os .system (command )
98+ else :
99+ with zipfile .ZipFile (archive_file_name , 'r' ) as zip_ref :
100+ zip_ref .extractall (download_dir )
101+ os .chmod (os .path .join (download_dir , binary_name ), 0o755 )
102+ except Exception as e :
103+ print ("ERROR: [_setup] %s" % (str (e )))
104+ exit (1 )
102105
103106def _get_version (bin_path ):
104107 try :
0 commit comments