Created
March 3, 2024 14:13
-
-
Save thorrr/931b5243fa02533a7b5d299adb986c11 to your computer and use it in GitHub Desktop.
Install the latest Jupyter 6.xx with extensions activated
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# shellcheck disable=SC2155 # irrelevant because of set -e | |
set -euo pipefail | |
readonly VENV_NAME=venv | |
readonly BLACK_LINE_LENGTH=110 | |
readonly packages=( | |
jupyter | |
jupyter_contrib_nbextensions | |
jupyter_nbextensions_configurator | |
# To enable jupytext, add the following to pyproject.toml: | |
# [tool.jupytext] | |
# formats = "ipynb,py:percent" | |
# or do | |
# echo 'formats = "ipynb,py:percent"' > jupytext.toml | |
# at the root of your notebook directory | |
jupytext | |
# temp fix for Jupyter Notebook ‘zmq message arrived on closed channel’ Error: | |
# https://youtrack.jetbrains.com/issue/DS-4883 | |
# and | |
# https://discourse.jupyter.org/t/jupyter-notebook-zmq-message-arrived-on-closed-channel-error/17869/27 | |
"jupyter_client<8" | |
"pyzmq < 25" | |
# all cool extentions and buttons are broken on jupyter 7 | |
'notebook < 7.0' | |
# pin traitlets until https://github.com/microsoft/azuredatastudio/issues/24436 is fixed | |
"traitlets==5.9.0" | |
# black and isort have to be in the venv for them to be run by our buttons | |
black | |
isort | |
) | |
$VENV_NAME/bin/pip install "${packages[@]}" --upgrade | |
$VENV_NAME/bin/jupyter contrib nbextension install --sys-prefix | |
$VENV_NAME/bin/jupyter nbextensions_configurator enable --sys-prefix | |
# Turn off annoying compat checking | |
echo '{"nbext_hide_incompat": false}' > $VENV_NAME/etc/jupyter/nbconfig/common.json | |
# Set up jupyter extensions. | |
$VENV_NAME/bin/jupyter nbextension enable code_prettify/isort --sys-prefix | |
$VENV_NAME/bin/jupyter nbextension install \ | |
https://github.com/drillan/jupyter-black/archive/master.zip --sys-prefix | |
$VENV_NAME/bin/jupyter nbextension enable jupyter-black-master/jupyter-black --sys-prefix | |
$VENV_NAME/bin/jupyter nbextension enable codefolding/main --sys-prefix | |
$VENV_NAME/bin/jupyter nbextension enable execute_time/ExecuteTime --sys-prefix | |
$VENV_NAME/bin/jupyter nbextension enable export_embedded/main --sys-prefix | |
$VENV_NAME/bin/jupyter nbextension enable python-markdown/main --sys-prefix | |
$VENV_NAME/bin/jupyter nbextension enable toggle_all_line_numbers/main --sys-prefix | |
$VENV_NAME/bin/jupyter nbextension enable scratchpad/main --sys-prefix | |
$VENV_NAME/bin/jupyter nbextension enable scroll_down/main --sys-prefix | |
$VENV_NAME/bin/jupyter nbextension enable toc2/main --sys-prefix | |
$VENV_NAME/bin/jupyter nbextension enable collapsible_headings/main --sys-prefix | |
$VENV_NAME/bin/jupyter nbextension enable livemdpreview/livemdpreview --sys-prefix | |
$VENV_NAME/bin/jupyter nbextension enable printview/main --sys-prefix | |
$VENV_NAME/bin/jupyter nbextension enable table_beautifier/main --sys-prefix | |
# Set our column width. | |
perl -pi -e "s/black.FileMode\(\)/black.FileMode\(line_length=${BLACK_LINE_LENGTH}\)/" \ | |
$VENV_NAME/share/jupyter/nbextensions/jupyter-black-master/jupyter-black.yaml | |
# Fix bug in outdated isort plugin | |
perl -pi -e "s/\(_isort_refactor_cell/\(isort.code/" \ | |
$VENV_NAME/share/jupyter/nbextensions/code_prettify/isort.js | |
# Turn off annoying "move menu left" feature in toc view | |
perl -pi -e 's/^{/{\n "toc2": {"moveMenuLeft": false},/' \ | |
$VENV_NAME/etc/jupyter/nbconfig/notebook.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment