Skip to content

Commit 23ddd99

Browse files
committed
fix: Enhance platform check for stackql installation(macOS)
1 parent e8d749a commit 23ddd99

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

Diff for: pystackql/_util.py

+21-18
Original file line numberDiff line numberDiff line change
@@ -81,24 +81,27 @@ def _download_file(url, path, showprogress=True):
8181

8282
def _setup(download_dir, platform, showprogress=False):
8383
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)
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 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

103106
def _get_version(bin_path):
104107
try:

0 commit comments

Comments
 (0)