Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2@file
3@brief Various functions to install `Julia <http://www.julialang.org/>`_.
4"""
5from __future__ import print_function
6import sys
7import re
8import os
10from ..installhelper.install_cmd_helper import run_cmd
11from .install_custom import download_page, download_file
14def get_julia_version():
15 """
16 returns the version of installed R,
17 we only focus on the x64 version
19 @return tuple (bin, version), None if R is not installed
20 """
21 if sys.platform.startswith("win"):
22 path = "{0}\\Julia".format(os.environ["ProgramFiles"])
23 if os.path.exists(path):
24 vers = os.listdir(path)
25 vers.sort()
26 if len(vers) == 0:
27 return None
28 vers = vers[-1]
29 bin = os.path.join(path, vers, "bin", "x64")
30 if not os.path.exists(bin):
31 return None
32 return (bin, vers)
33 return None
34 else:
35 raise NotImplementedError("not available on platform " + sys.platform)
38def IsJuliaInstalled():
39 """
40 @return True of False whether or not it was installed
41 """
42 r = get_julia_version()
43 return r is not None
46def install_julia(
47 temp_folder=".", fLOG=print, install=True, force_download=False, version=None):
48 """
49 Install `R <http://www.r-project.org/>`_.
50 It does not do it a second time if it is already installed.
52 @param temp_folder where to download the setup
53 @param fLOG logging function
54 @param install install (otherwise only download)
55 @param force_download force the downloading of Julia
56 @param version version to download (unused)
57 @return temporary file
58 """
59 if version is not None:
60 raise ValueError("cannot specify a version")
61 bb = IsJuliaInstalled()
62 if bb and not force_download:
63 return True
65 link = "http://julialang.org/downloads/"
66 page = download_page(link)
67 if sys.platform.startswith("win"):
68 reg = re.compile("href=\\\"(.*?win64[.]exe)\\\"")
69 alls = reg.findall(page)
70 if len(alls) == 0:
71 raise Exception(
72 "unable to find a link on a .exe file on page: " +
73 page)
75 url = alls[0]
76 full = url.split("/")[-1]
77 outfile = os.path.join(temp_folder, full)
78 fLOG("[pymy] download ", url)
79 local = download_file(url, outfile)
80 if install and not bb:
81 run_cmd("msiexec /i " + local, fLOG=fLOG, wait=True)
82 return local
83 else:
84 raise NotImplementedError("not available on platform " + sys.platform)