Skip to content

Commit

Permalink
Add support for private IPython install on Win
Browse files Browse the repository at this point in the history
  • Loading branch information
davidanthoff committed Mar 3, 2015
1 parent 637dc96 commit 6d5f482
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.pyc
*.un~
/build/
/deps/downloads
/deps/usr
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ JSON 0.2-
ZMQ 0.1-
REPLCompletions
Compat 0.2
BinDeps
52 changes: 52 additions & 0 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,58 @@ eprintln(x...) = println(STDERR, x...)

juliaprofiles = Array(String,0)

@windows_only begin
ipython_version_to_install = "2.4.1"

existing_install_tag_filename = normpath(pwd(),"usr","python342-exists")
downloadsdir = normpath(pwd(), "downloads")
pythonzipfilename = normpath(pwd(), "downloads", "python-3.4.2.zip")
pyinstalldir = normpath(pwd(),"usr","python34")
pythonexepath = normpath(pwd(),"usr","python34","python.exe")
ijuliaprofiledir = normpath(pwd(), "usr", ".ijulia")

upgrade_private_python = ispath(existing_install_tag_filename)

if upgrade_private_python
rm(existing_install_tag_filename)

run(`$pythonexepath -m pip install -U pip`)
run(`$pythonexepath -m pip install -U ipython[notebook]==$ipython_version_to_install`)
else
using BinDeps

if ispath(downloadsdir)
rm(downloadsdir, recursive=true)
end

if ispath(normpath(pwd(),"usr"))
rm(normpath(pwd(),"usr"), recursive=true)
end

mkdir(downloadsdir)

run(download_cmd("https://sourceforge.net/projects/minimalportablepython/files/python-3.4.2.zip", "$pythonzipfilename"))

run(`7z x $pythonzipfilename -y -o$pyinstalldir`)

run(`$pythonexepath -m ensurepip`)
run(`$pythonexepath -m pip install -U pip`)

run(`$pythonexepath -m pip install ipython[notebook]==$ipython_version_to_install`)
end

if ispath(ijuliaprofiledir)
rm(ijuliaprofiledir, recursive=true)
end

run(`$pythonexepath -m IPython profile create --ipython-dir="$ijuliaprofiledir"`)

internaljuliaprof = chomp(readall(`$pythonexepath -m IPython locate profile --ipython-dir="$ijuliaprofiledir"`))
push!(juliaprofiles, internaljuliaprof)

touch(existing_install_tag_filename)
end

include("ipython.jl")
const ipython, ipyvers = find_ipython()

Expand Down
10 changes: 9 additions & 1 deletion src/IJulia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,15 @@ end
export notebook
function notebook(ipython=find_ipython()[1])
inited && error("IJulia is already running")
run(`$ipython notebook --profile julia`)

if @windows ? true : false
pythonexe = normpath(Pkg.dir("IJulia"),"deps", "usr", "python34", "python.exe")
ijuliaprofiledir = normpath(Pkg.dir("IJulia"), "deps", "usr", ".ijulia")
run(`$pythonexe -m IPython notebook --ipython-dir="$ijuliaprofiledir"`)
else
ipython[1]==nothing && error("IPython not found")
run(`$ipython notebook --profile julia`)
end
end

end # IJulia
Expand Down

0 comments on commit 6d5f482

Please sign in to comment.