jupyterlab: install and link jupyterlab, not only deps.
Fixes: - jupyterlab was being downloaded but not pip installed or linked. - dependency on 'node' wasn't declared, which became needed once jupyterlab got installed and linked. Changes: - Changed install to use virtualenv. - Added a couple of tests to ensure that jupyterlab Python package and jupyter-lab binary are actually installed. Closes #47340. Signed-off-by: Rui Chen <chenrui333@gmail.com>
This commit is contained in:
parent
5683adef0c
commit
8a120c31b3
1 changed files with 18 additions and 18 deletions
|
@ -1,8 +1,11 @@
|
|||
class Jupyterlab < Formula
|
||||
include Language::Python::Virtualenv
|
||||
|
||||
desc "Interactive environments for writing and running code"
|
||||
homepage "https://jupyter.org/"
|
||||
url "https://files.pythonhosted.org/packages/57/a8/9aea7e00e8634f6e73bc2641033fee2d59e5d506784474e5e5d55eb15d55/jupyterlab-1.2.0.tar.gz"
|
||||
sha256 "ce945579a6b20628d275efd4debffef96fa66ef83a10a62d7087ca5610b61668"
|
||||
revision 1
|
||||
|
||||
bottle do
|
||||
cellar :any
|
||||
|
@ -12,6 +15,7 @@ class Jupyterlab < Formula
|
|||
end
|
||||
|
||||
depends_on "ipython"
|
||||
depends_on "node"
|
||||
depends_on "pandoc"
|
||||
depends_on "python"
|
||||
depends_on "zeromq"
|
||||
|
@ -242,32 +246,18 @@ class Jupyterlab < Formula
|
|||
end
|
||||
|
||||
def install
|
||||
venv = virtualenv_create(libexec, "python3")
|
||||
ENV["JUPYTER_PATH"] = etc/"jupyter"
|
||||
xy = Language::Python.major_minor_version "python3"
|
||||
ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python#{xy}/site-packages"
|
||||
|
||||
# gather packages to link based on options
|
||||
linked = %w[jupyter-core jupyter-client nbformat ipykernel jupyter-console
|
||||
nbconvert notebook]
|
||||
dependencies = resources.map(&:name).to_set - linked
|
||||
|
||||
# install dependent packages
|
||||
dependencies.each do |r|
|
||||
resource(r).stage do
|
||||
system "python3", *Language::Python.setup_install_args(libexec/"vendor")
|
||||
end
|
||||
venv.pip_install resource(r)
|
||||
end
|
||||
|
||||
# install main packages and link with env script
|
||||
ENV.prepend_create_path "PYTHONPATH", libexec/"lib/python#{xy}/site-packages"
|
||||
linked.each do |r|
|
||||
resource(r).stage do
|
||||
system "python3", *Language::Python.setup_install_args(libexec)
|
||||
end
|
||||
end
|
||||
|
||||
bin.install Dir["#{libexec}/bin/*"]
|
||||
bin.env_script_all_files(libexec/"bin", :JUPYTER_PATH => ENV["JUPYTER_PATH"], :PYTHONPATH => ENV["PYTHONPATH"])
|
||||
venv.pip_install_and_link linked
|
||||
venv.pip_install_and_link buildpath
|
||||
|
||||
# remove bundled kernel
|
||||
rm_rf Dir["#{libexec}/share/jupyter/kernels"]
|
||||
|
@ -311,5 +301,15 @@ class Jupyterlab < Formula
|
|||
|
||||
assert_match "-F _jupyter",
|
||||
shell_output("source #{bash_completion}/jupyter && complete -p jupyter")
|
||||
|
||||
version_regexp = Regexp.quote(version.to_s)
|
||||
|
||||
# Ensure that jupyter can load the jupyter lab package.
|
||||
assert_match /^jupyter lab *: #{version_regexp}$/,
|
||||
shell_output(bin/"jupyter --version")
|
||||
|
||||
# Ensure that jupyter-lab binary was installed by pip.
|
||||
assert_match /^#{version_regexp}$/,
|
||||
shell_output(bin/"jupyter-lab --version")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue