|
1 | 1 | import hashlib |
2 | 2 | import io |
| 3 | +import gzip |
3 | 4 | import json |
4 | 5 | import os |
5 | 6 | import platform |
@@ -97,18 +98,19 @@ def install_julia(vers, prefix): |
97 | 98 | for f in vers[v]['files']: |
98 | 99 | url = f['url'] |
99 | 100 | if url.endswith('.tar.gz'): |
100 | | - installer = install_julia_tar |
| 101 | + installer = install_julia_tar_gz |
101 | 102 | elif url.endswith('.zip'): |
102 | 103 | installer = install_julia_zip |
103 | 104 | elif url.endswith('.dmg'): |
104 | 105 | installer = install_julia_dmg |
105 | 106 | else: |
106 | 107 | continue |
107 | 108 | 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) |
112 | 114 | return |
113 | 115 | raise Exception('no installable Julia version found') |
114 | 116 |
|
@@ -156,10 +158,11 @@ def install_julia_zip(f, buf, prefix): |
156 | 158 | os.rename(os.path.join(prefix, top, fn), os.path.join(prefix, fn)) |
157 | 159 | os.rmdir(os.path.join(prefix, top)) |
158 | 160 |
|
159 | | -def install_julia_tar(f, buf, prefix): |
| 161 | +def install_julia_tar_gz(f, buf, prefix): |
160 | 162 | 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) |
163 | 166 | fns = os.listdir(prefix) |
164 | 167 | if 'bin' not in fns: |
165 | 168 | if len(fns) != 1: |
|
0 commit comments