#/bin/bash
set -x
rm -rf test
mkdir test; cd test
python3.10 -m venv foo_venv
source foo_venv/bin/activate 2>> /dev/null
pip install pip setuptools --upgrade >> /dev/null
pip install notebook >> /dev/null
ipython kernel install --name foo_venv --prefix=./foo_venv >> .install.log
jupyter kernelspec list | grep -E "^\s*foo_venv(\s.*)?$"
cp ../foo.ipynb .
cat foo.ipynb
export JUPYTER_CONFIG_DIR=$(pwd)/foo_venv/etc/jupyter/
echo $JUPYTER_CONFIG_DIR
jupyter migrate # mine says [JupyterMigrate] Found nothing to migrate.
mkdir -p foo_venv/etc/jupyter/custom
cp ../custom.js foo_venv/etc/jupyter/custom/
date
stat foo_venv/etc/jupyter/custom/custom.js
# BTW, *without* editing ```foo.ipynb```, how can I tell it to just launch this kernel without the popup?
jupyter-notebook foo.ipynb --MultiKernelManager.default_kernel_name=foo_venv 2>> /dev/null
stat foo_venv/etc/jupyter/custom/custom.js
date
cat foo_venv/etc/jupyter/custom/custom.js # doing after so as not to change the access/creation times
cd ..
deactivate 2>> /dev/null
set +x
To run: chmod +x test.sh; ./test.sh
Creates a dir test, goes into it
makes and activates venv foo_venv
installs notebook
installs foo_venv kernel locally (in (./)foo_venv/share/jupyter/kernels/foo_venv)
puts custom.js into ${JUPYTER_CONFIG_DIR}=$(pwd)/foo_venv/etc/jupyter in /custom
stats custom.js
runs minimal notebook foo.ipynb (See comment above about getting notebook to “just launch” the kernel)* (Ctrl-C or File->Shut Down to exit.)
stats custom.js again.
++ date
Sun Aug 20 14:44:00 EDT 2023
++ stat foo_venv/etc/jupyter/custom/custom.js
16777220 261616118 -rw-r--r-- 1 me me 0 35 "Aug 20 14:44:00 2023" "Aug 20 14:44:00 2023" "Aug 20 14:44:00 2023" "Aug 20 14:44:00 2023" 4096 8 0 foo_venv/etc/jupyter/custom/custom.js
++ jupyter-notebook foo.ipynb --MultiKernelManager.default_kernel_name=foo_venv
++ stat foo_venv/etc/jupyter/custom/custom.js
16777220 261616118 -rw-r--r-- 1 me me 0 35 "Aug 20 14:44:05 2023" "Aug 20 14:44:00 2023" "Aug 20 14:44:00 2023" "Aug 20 14:44:00 2023" 4096 8 0 foo_venv/etc/jupyter/custom/custom.js
++ date
Sun Aug 20 14:44:15 EDT 2023
Clearly something jupyter-notebook did accessed custom.js, but I don’t see “custom log message” in the console log.