aboutsummaryrefslogtreecommitdiff
path: root/collection/jupyterlab
diff options
context:
space:
mode:
authorJosh Spicer <josh@joshspicer.com>2022-05-10 01:16:15 +0300
committerGitHub <noreply@github.com>2022-05-10 01:16:15 +0300
commit9efe4b3c4a5f07c45cf6ed69900006eed0e844b9 (patch)
tree1c120109a1794b913a3c71df0a456eb0ad411a54 /collection/jupyterlab
parent8759124c532d93b6e1ab38e391554d287b956d83 (diff)
init (#1)
* init * some copy pastin * install.sh ref * fixes
Diffstat (limited to 'collection/jupyterlab')
-rw-r--r--collection/jupyterlab/feature.json21
-rw-r--r--collection/jupyterlab/install.sh51
2 files changed, 72 insertions, 0 deletions
diff --git a/collection/jupyterlab/feature.json b/collection/jupyterlab/feature.json
new file mode 100644
index 0000000..e080339
--- /dev/null
+++ b/collection/jupyterlab/feature.json
@@ -0,0 +1,21 @@
+{
+ "id": "jupyterlab",
+ "name": "Jupyter Lab",
+ "options": {
+ "version": {
+ "type": "string",
+ "proposals": ["latest", "3.6.2"],
+ "default": "latest",
+ "description": "Select or enter a jupyterlab version."
+ }
+ },
+ "extensions": [
+ "ms-python.python",
+ "ms-python.vscode-pylance",
+ "ms-toolsai.jupyter"
+ ],
+ "install": {
+ "app": "",
+ "file": "install.sh"
+ }
+} \ No newline at end of file
diff --git a/collection/jupyterlab/install.sh b/collection/jupyterlab/install.sh
new file mode 100644
index 0000000..45267b0
--- /dev/null
+++ b/collection/jupyterlab/install.sh
@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+
+set -e
+
+VERSION=${1:-"latest"}
+USERNAME=${2:-"automatic"}
+
+# If in automatic mode, determine if a user already exists, if not use vscode
+if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
+ USERNAME=""
+ POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)")
+ for CURRENT_USER in ${POSSIBLE_USERS[@]}; do
+ if id -u ${CURRENT_USER} > /dev/null 2>&1; then
+ USERNAME=${CURRENT_USER}
+ break
+ fi
+ done
+ if [ "${USERNAME}" = "" ]; then
+ USERNAME=vscode
+ fi
+elif [ "${USERNAME}" = "none" ]; then
+ USERNAME=root
+ USER_UID=0
+ USER_GID=0
+fi
+
+# Use sudo to run as non-root user is not already running
+sudoUserIf()
+{
+ if [ "$(id -u)" -eq 0 ] && [ "${USERNAME}" != "root" ]; then
+ sudo -u ${USERNAME} "$@"
+ else
+ "$@"
+ fi
+}
+
+# If we don't yet have Python, install it now.
+if ! python --version > /dev/null ; then
+ echo "You need to install Python before installing JupyterLab."
+ exit 1
+fi
+
+# If we don't already have JupyterLab installed, install it now.
+if ! jupyter-lab --version > /dev/null ; then
+ echo "Installing JupyterLab..."
+ if [ "${VERSION}" = "latest" ]; then
+ pip install jupyterlab
+ else
+ pip install jupyterlab=="${VERSION}" --no-cache-dir
+ fi
+fi