Skip to content

Commit

Permalink
more informative error message when JUPYTER is not a valid executable
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Feb 22, 2018
1 parent eb3ca86 commit 397d190
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,40 @@ try
ENV["PYTHONIOENCODING"] = "UTF-8"

function prog_version(prog)
v = try
chomp(read(`$prog --version`, String))
catch
return nothing
end
try
return convert(VersionNumber, chomp(read(`$prog --version`, String)))
return convert(VersionNumber, v)
catch
return v"0.0"
warn("`$jupyter --version` returned an unrecognized version number $v")
return v"0.0"
end
end

global jupyter = get(ENV, "JUPYTER", isfile("JUPYTER") ? readchomp("JUPYTER") : Compat.Sys.islinux() ? "jupyter" : "")
jupyter_vers = isempty(jupyter) ? v"0.0" : prog_version(jupyter)
if (jupyter_vers == v"0.0") # some Linux distributions (Debian) use jupyter-notebook to launch Jupyter
jupyter_vers = prog_version(jupyter * "-notebook")
if isempty(jupyter)
jupyter_vers = nothing
else
jupyter_vers = prog_version(jupyter)
if jupyter_vers === nothing
jupyter_vers = prog_version(jupyter * "-notebook")
end
if jupyter_vers === nothing
warn("Could not execute `$jupyter --version`.")
end
end
isconda = dirname(jupyter) == abspath(Conda.SCRIPTDIR)
if Sys.ARCH in (:i686, :x86_64) && (jupyter_vers < v"3.0" || isconda)
isempty(jupyter) || isconda || info("$jupyter was too old: got $jupyter_vers, required ≥ 3.0")
if Sys.ARCH in (:i686, :x86_64) && (jupyter_vers === nothing || jupyter_vers < v"3.0" || isconda)
isconda || jupyter_vers === nothing || info("$jupyter was too old: got $jupyter_vers, required ≥ 3.0")
info("Installing Jupyter via the Conda package.")
Conda.add("jupyter")
jupyter = abspath(Conda.SCRIPTDIR, "jupyter")
jupyter_vers = prog_version(jupyter)
end
if jupyter_vers < v"3.0"
if jupyter_vers === nothing || jupyter_vers < v"3.0"
error("Failed to find or install Jupyter 3.0 or later. Please install Jupyter manually, set `ENV[\"JUPYTER\"]=\"/path/to/jupyter\", and rerun `Pkg.build(\"IJulia\")`.")
end
info("Found Jupyter version $jupyter_vers: $jupyter")
Expand Down

0 comments on commit 397d190

Please sign in to comment.