diff --git a/deps/build.jl b/deps/build.jl index 510224cd..39aa789f 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -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")