Skip to content

Commit 5f2bac5

Browse files
author
Christopher Doris
committed
install
1 parent c663f7e commit 5f2bac5

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

juliacall/install.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import hashlib
22
import io
3+
import gzip
34
import json
45
import os
56
import platform
@@ -97,18 +98,19 @@ def install_julia(vers, prefix):
9798
for f in vers[v]['files']:
9899
url = f['url']
99100
if url.endswith('.tar.gz'):
100-
installer = install_julia_tar
101+
installer = install_julia_tar_gz
101102
elif url.endswith('.zip'):
102103
installer = install_julia_zip
103104
elif url.endswith('.dmg'):
104105
installer = install_julia_dmg
105106
else:
106107
continue
107108
buf = download_julia(f)
108-
print(f'Installing Julia to {prefix}')
109-
if os.path.exists(prefix):
110-
shutil.rmtree(prefix)
111-
installer(f, buf, prefix)
109+
prefix2 = prefix.format(version=v)
110+
print(f'Installing Julia to {prefix2}')
111+
if os.path.exists(prefix2):
112+
shutil.rmtree(prefix2)
113+
installer(f, buf, prefix2)
112114
return
113115
raise Exception('no installable Julia version found')
114116

@@ -156,10 +158,11 @@ def install_julia_zip(f, buf, prefix):
156158
os.rename(os.path.join(prefix, top, fn), os.path.join(prefix, fn))
157159
os.rmdir(os.path.join(prefix, top))
158160

159-
def install_julia_tar(f, buf, prefix):
161+
def install_julia_tar_gz(f, buf, prefix):
160162
os.makedirs(prefix)
161-
with tarfile.TarFile(fileobj=buf) as tf:
162-
tf.extractall(prefix)
163+
with gzip.GzipFile(fileobj=buf) as gf:
164+
with tarfile.TarFile(fileobj=gf) as tf:
165+
tf.extractall(prefix)
163166
fns = os.listdir(prefix)
164167
if 'bin' not in fns:
165168
if len(fns) != 1:

0 commit comments

Comments
 (0)