-
Notifications
You must be signed in to change notification settings - Fork 20
/
install_julia.py
66 lines (44 loc) · 1.63 KB
/
install_julia.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
58
59
60
61
#!/usr/bin/python3
import os
import sys
import subprocess
mpath = os.path.dirname(os.path.realpath(__file__))
# main path
try:
out,err = subprocess.Popen(['julia', '--version'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT).communicate()
except: out = ""
# check if JUlia has the correct version
hasjulia = "julia version 1.5" in str(out)
#print(hasjulia) ; exit()
if not hasjulia: # if the correct Julia version is not present
print("Julia not present in path, downloading")
os.system("mkdir "+mpath+"/src/julia") # create a subfodler for julia
os.chdir(mpath+"/src/julia") # go to the subfolder
# download julia
juliafile = "julia-1.5.0-linux-x86_64.tar.gz" # julia file
os.system("wget https://julialang-s3.julialang.org/bin/linux/x64/1.5/"+juliafile)
os.system("tar -xvf "+juliafile) # untar the file
os.system("rm "+juliafile) # rm the file
julia = mpath+"/src/julia/julia-1.5.0/bin/julia" # path for julia
os.chdir(mpath) # go back
else:
julia = "julia"
print("Correct Julia version found in path")
# install python dependences
os.system("pip install julia")
os.system("pip install pmdarima")
# install Itensor julia
import src.dmrgpy.juliarun as juliarun
juliarun.install() # install Julia dependences
##################
# and add dmrgpy to the python path
def get_lp():
for p in sys.path:
if "/site-packages" in p: return p
print("Path to add the Python library not found")
exit()
p = get_lp()+"/dmrgpy" # get the path
os.system("rm -f "+p) # remove the symbolic link
os.system("ln -s "+mpath+"/src/dmrgpy "+p) # remove the symbolic link