Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes for 0.7 #671

Merged
merged 20 commits into from
Jul 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.un~
/build/
/deps/deps.jl
/deps/build.log
/deps/JUPYTER
/deps/julia-*
*.jl.*.cov
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ os:
julia:
- 0.6
- nightly
matrix:
allow_failures:
- julia: nightly
notifications:
email: false
script:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ is `IJulia.load("filename")`.

### Prompting for user input

When you are running in a notebook, ordinary I/O functions on `STDIN` do
When you are running in a notebook, ordinary I/O functions on `stdin` do
not function. However, you can prompt for the user to enter a string
in one of two ways:

* `readline()` and `readline(STDIN)` both open a `STDIN>` prompt widget where the user can enter a string, which is returned by `readline`.
* `readline()` and `readline(stdin)` both open a `stdin>` prompt widget where the user can enter a string, which is returned by `readline`.

* `IJulia.readprompt(prompt)` displays the prompt string `prompt` and
returns a string entered by the user. `IJulia.readprompt(prompt, password=true)` does the same thing but hides the text the user types.
Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ julia 0.6
MbedTLS 0.4.3
JSON 0.17
ZMQ 0.6.0
Compat 0.41.0
Compat 0.68.0
Conda 0.1.5
7 changes: 1 addition & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ branches:
- master
- /release-.*/

matrix:
allow_failures:
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"

notifications:
- provider: Email
on_build_success: false
Expand All @@ -38,7 +33,7 @@ install:
build_script:
- C:\projects\julia\bin\julia -e "versioninfo(true);
Pkg.clone(pwd(), \"IJulia\");
using Conda;
Pkg.add(\"Conda\"); using Conda;
try Conda.add(\"qt\") end;
postlink = normpath(Pkg.dir(\"Conda\"), \"deps/usr/pkgs/qt-4.8.7-vc9_9/Scripts/.qt-post-link.bat\");
isfile(postlink) && rm(postlink);
Expand Down
21 changes: 11 additions & 10 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ function prog_version(prog)
return nothing
end
try
return convert(VersionNumber, v)
return VersionNumber(v)
catch
warn("`$jupyter --version` returned an unrecognized version number $v")
Compat.@warn("`$jupyter --version` returned an unrecognized version number $v")
return v"0.0"
end
end
Expand All @@ -35,21 +35,21 @@ else
jupyter_vers = prog_version(jupyter * "-notebook")
end
if jupyter_vers === nothing
warn("Could not execute `$jupyter --version`.")
Compat.@warn("Could not execute `$jupyter --version`.")
end
end
isconda = dirname(jupyter) == abspath(Conda.SCRIPTDIR)
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.")
isconda || jupyter_vers === nothing || Compat.@info("$jupyter was too old: got $jupyter_vers, required ≥ 3.0")
Compat.@info("Installing Jupyter via the Conda package.")
Conda.add("jupyter")
jupyter = abspath(Conda.SCRIPTDIR, "jupyter")
jupyter_vers = prog_version(jupyter)
end
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")
Compat.@info("Found Jupyter version $jupyter_vers: $jupyter")

#######################################################################
# Get the latest syntax highlighter file.
Expand All @@ -64,7 +64,7 @@ if isconda
try
download(highlighter_url, highlighter)
catch e
warn("The following error occurred while attempting to download latest ",
Compat.@warn("The following error occurred while attempting to download latest ",
"syntax highlighting definitions:\n\n", e, "\n\nSyntax highlighting may ",
"not work as expected.")
end
Expand All @@ -75,10 +75,11 @@ end
# Warn people upgrading from older IJulia versions:
try
juliaprof = chomp(read(pipeline(`$ipython locate profile julia`,
stderr=DevNull), String))
warn("""You should now run IJulia just via `$jupyter notebook`, without
stderr=devnull), String))
Compat.@warn("""You should now run IJulia just via `$jupyter notebook`, without
the `--profile julia` flag. IJulia no longer maintains the profile.
Consider deleting $juliaprof""")
catch
end

#######################################################################
Expand All @@ -91,7 +92,7 @@ kspec_cmd, = installkernel("Julia")
# "kernelspec" with "notebook":
notebook = kspec_cmd.exec
n = notebook[end]
ki = rsearch(n, "kernelspec")
ki = VERSION < v"0.7.0-DEV.3252" ? rsearch(n, "kernelspec") : findlast("kernelspec", n)
notebook[end] = n[1:prevind(n,first(ki))] * "notebook" * n[nextind(n,last(ki)):end]

#######################################################################
Expand Down
10 changes: 5 additions & 5 deletions deps/kspec.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#######################################################################
# Install Jupyter kernel-spec file.

copy_config(src, dest) = cp(src, joinpath(dest, basename(src)), remove_destination=true)
copy_config(src, dest) = Compat.cp(src, joinpath(dest, basename(src)), force=true)

"""
installkernel(name, options...; specname=replace(lowercase(name), " ", "-")
installkernel(name, options...; specname=replace(lowercase(name), " "=>"-")

Install a new Julia kernel, where the given `options` are passed to the `julia`
executable, and the user-visible kernel name is given by `name` followed by the
Expand All @@ -31,7 +31,7 @@ run(`\$kernelspec remove -f \$kernelname`)
```
"""
function installkernel(name::AbstractString, julia_options::AbstractString...;
specname::AbstractString = replace(lowercase(name), " ", "-"))
specname::AbstractString = replace(lowercase(name), " "=>"-"))
# Is IJulia being built from a debug build? If so, add "debug" to the description.
debugdesc = ccall(:jl_is_debugbuild,Cint,())==1 ? "-debug" : ""

Expand All @@ -41,7 +41,7 @@ function installkernel(name::AbstractString, julia_options::AbstractString...;
juliakspec = joinpath(tempdir(), spec_name)
try
binary_name = Compat.Sys.iswindows() ? "julia.exe" : "julia"
kernelcmd_array = String[joinpath(JULIA_HOME,"$binary_name"), "-i",
kernelcmd_array = String[joinpath(Compat.Sys.BINDIR,"$binary_name"), "-i",
"--startup-file=yes", "--color=yes"]
append!(kernelcmd_array, julia_options)
ijulia_dir = get(ENV, "IJULIA_DIR", dirname(@__DIR__)) # support non-Pkg IJulia installs
Expand All @@ -65,7 +65,7 @@ function installkernel(name::AbstractString, julia_options::AbstractString...;
copy_config(joinpath(ijulia_dir,"deps","logo-32x32.png"), juliakspec)
copy_config(joinpath(ijulia_dir,"deps","logo-64x64.png"), juliakspec)

info("Installing $name kernelspec $spec_name")
Compat.@info("Installing $name kernelspec $spec_name")

# remove these hacks when
# https://github.com/jupyter/notebook/issues/448 is closed and the fix
Expand Down
14 changes: 9 additions & 5 deletions src/IJulia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ export notebook, installkernel
using ZMQ, JSON, Compat
import Compat.invokelatest
using Compat.Unicode: uppercase, lowercase
import Compat.Dates
using Compat.Dates: now
import Compat.Random
using Compat.Base64: Base64EncodePipe
using Compat.REPL

#######################################################################
# Debugging IJulia
Expand Down Expand Up @@ -109,10 +113,10 @@ function notebook(; dir=homedir(), detached=false)
inited && error("IJulia is already running")
if Compat.Sys.isapple() # issue #551 workaround, remove after macOS 10.12.6 release?
withenv("BROWSER"=>"open") do
p = spawn(Cmd(`$notebook_cmd`, detach=true, dir=dir))
p = run(Cmd(`$notebook_cmd`, detach=true, dir=dir); wait=false)
end
else
p = spawn(Cmd(`$notebook_cmd`, detach=true, dir=dir))
p = run(Cmd(`$notebook_cmd`, detach=true, dir=dir); wait=false)
end
if !detached
try
Expand Down Expand Up @@ -198,7 +202,7 @@ function clear_history(indices)
end

# since a range could be huge, intersect it with 1:n first
clear_history{T<:Integer}(r::AbstractRange{T}) =
clear_history(r::AbstractRange{T}) where {T<:Integer} =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can just be clear_history(r::AbstractRange{<:Integer}) since we don't use T.

invoke(clear_history, Tuple{Any}, intersect(r, 1:n))

function clear_history()
Expand Down Expand Up @@ -232,7 +236,7 @@ function history(io::IO, indices::AbstractVector{Int})
end

history(io::IO, x::Union{Integer,AbstractVector{Int}}...) = history(io, vcat(x...))
history(x...) = history(STDOUT, x...)
history(x...) = history(stdout, x...)
history(io::IO, x...) = throw(MethodError(history, (x...,)))
history() = history(1:n)
"""
Expand All @@ -245,7 +249,7 @@ The optional `indices` argument is one or more indices or collections
of indices indicating a subset input cells to print.

The optional `io` argument is for specifying an output stream. The default
is `STDOUT`.
is `stdout`.
"""
history

Expand Down
6 changes: 3 additions & 3 deletions src/comm_manager.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import IJulia: Msg, uuid4, send_ipython, msg_pub
export Comm, comm_target, msg_comm, send_comm, close_comm,
register_comm, comm_msg, comm_open, comm_close, comm_info_request

type Comm{target}
mutable struct Comm{target}
id::String
primary::Bool
on_msg::Function
on_close::Function
function (::Type{Comm{target}}){target}(id, primary, on_msg, on_close)
function (::Type{Comm{target}})(id, primary, on_msg, on_close) where {target}
comm = new{target}(id, primary, on_msg, on_close)
comms[id] = comm
return comm
Expand Down Expand Up @@ -42,7 +42,7 @@ function Comm(target,
return comm
end

comm_target{target}(comm :: Comm{target}) = target
comm_target(comm :: Comm{target}) where {target} = target

function comm_info_request(sock, msg)
reply = if haskey(msg.content, "target_name")
Expand Down
2 changes: 1 addition & 1 deletion src/eventloop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function eventloop(socket)
# kernel interruption to interrupt long calculations.)
if !isa(e, InterruptException)
content = error_content(e, msg="KERNEL EXCEPTION")
map(s -> println(orig_STDERR[], s), content["traceback"])
map(s -> println(orig_stderr[], s), content["traceback"])
send_ipython(publish[], msg_pub(execute_msg, "error", content))
end
finally
Expand Down
Loading