Skip to content

Commit

Permalink
Merge pull request #201304 from Homebrew/jupyterlab-venv
Browse files Browse the repository at this point in the history
jupyterlab: use `virtualenv_install_with_resources`
  • Loading branch information
BrewTestBot authored Dec 16, 2024
2 parents e8cecf2 + e1df5e5 commit 2c7fa3f
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions Formula/j/jupyterlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -519,13 +519,11 @@ def python3
end

def install
venv = virtualenv_create(libexec, python3)
ENV["JUPYTER_PATH"] = etc/"jupyter"

# install packages into virtualenv and link all jupyter extensions
skipped = %w[hatch-jupyter-builder hatch-nodejs-version jupyterlab-pygments notebook]
venv.pip_install resources.reject { |r| skipped.include? r.name }
venv.pip_install_and_link buildpath
venv = virtualenv_install_with_resources without: skipped
bin.install_symlink (libexec/"bin").glob("jupyter*")

# These resources require `jupyterlab` to build, causing a build loop
Expand Down Expand Up @@ -578,29 +576,25 @@ def caveats
EOS
assert_match "ServerApp", shell_output("expect -f notebook.exp")

(testpath/"nbconvert.ipynb").write <<~EOS
(testpath/"nbconvert.ipynb").write <<~JSON
{
"cells": []
}
EOS
JSON
system bin/"jupyter-nbconvert", "nbconvert.ipynb", "--to", "html"
assert_predicate testpath/"nbconvert.html", :exist?, "Failed to export HTML"
assert_path_exists testpath/"nbconvert.html", "Failed to export HTML"

assert_match "-F _jupyter",
shell_output("bash -c \"source #{bash_completion}/jupyter && complete -p jupyter\"")
assert_match "-F _jupyter", shell_output("bash -c 'source #{bash_completion}/jupyter && complete -p jupyter'")

# Ensure that jupyter can load the jupyter lab package.
assert_match(/^jupyterlab *: #{version}$/,
shell_output(bin/"jupyter --version"))
assert_match(/^jupyterlab *: #{version}$/, shell_output(bin/"jupyter --version"))

# Ensure that jupyter-lab binary was installed by pip.
assert_equal version.to_s,
shell_output(bin/"jupyter-lab --version").strip
assert_equal version.to_s, shell_output(bin/"jupyter-lab --version").strip

port = free_port
fork { exec "#{bin}/jupyter-lab", "-y", "--port=#{port}", "--no-browser", "--ip=127.0.0.1", "--LabApp.token=''" }
spawn "#{bin}/jupyter-lab", "-y", "--port=#{port}", "--no-browser", "--ip=127.0.0.1", "--LabApp.token=''"
sleep 15
assert_match "<title>JupyterLab</title>",
shell_output("curl --silent --fail http://localhost:#{port}/lab")
assert_match "<title>JupyterLab</title>", shell_output("curl --silent --fail http://localhost:#{port}/lab")
end
end

0 comments on commit 2c7fa3f

Please sign in to comment.