-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup-linux.py
executable file
·57 lines (47 loc) · 1.86 KB
/
setup-linux.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# setup-linux.py
from os import environ, mkdir, remove
from os.path import exists, expanduser, join
from platform import machine as machine_architecture
from subprocess import check_call
from sys import version_info
import tarfile
if version_info.major == 2:
from urllib import urlretrieve
else:
from urllib.request import urlretrieve
address_julia_linux64 = 'https://julialang-s3.julialang.org/bin/linux/x64/0.6/julia-0.6.0-linux-x86_64.tar.gz'
address_julia_linux32 = 'https://julialang-s3.julialang.org/bin/linux/x86/0.6/julia-0.6.0-linux-i686.tar.gz'
def namefile(filename, suffix):
if not exists(filename + suffix):
return filename + suffix
count = 1
while exists(filename + str(count) + suffix):
count = count + 1
return filename + str(count) + suffix
filename = 'juila-0.6'
filesuffix = '.tar.gz'
foldername = expanduser('~/.julia/')
if not exists(foldername):
mkdir(foldername)
filename = namefile(join(foldername, filename), filesuffix)
try:
if machine_architecture().endswith('64'):
urlretrieve(address_julia_linux64, filename)
else:
urlretrieve(address_julia_linux32, filename)
tar = tarfile.open(filename)
tar.extractall(foldername, tar.getmembers())
finally:
remove(filename)
target = join(foldername, 'julia-903644385b/bin/julia')
check_call(['ln', '-s', target, '/usr/local/bin/julia'])
'''if target not in environ["PATH"]:
if exists(expanduser('~/.bashrc')):
with open(expanduser('~/.bashrc'), 'a') as fout:
fout.write('export PATH=$PATH:' + target + ' # Added by Pyglrm \n')
if exists(expanduser('~/.bash_profile')):
with open(expanduser('~/.bash_profile'), 'a') as fout:
fout.write('export PATH=$PATH:' + target + ' # Added by Pyglrm \n')
elif exists(expanduser('~/.profile')):
with open(expanduser('~/.profile'), 'a') as fout:
fout.write('export PATH=$PATH:' + target + ' # Added by Pyglrm \n')'''