Commit 1620def8 authored by Josh Spicer's avatar Josh Spicer Committed by GitHub
parents 5332b952 73e20e52
...@@ -7,6 +7,12 @@ ...@@ -7,6 +7,12 @@
"proposals": ["latest", "3.6.2"], "proposals": ["latest", "3.6.2"],
"default": "latest", "default": "latest",
"description": "Select or enter a jupyterlab version." "description": "Select or enter a jupyterlab version."
},
"pythonBinary": {
"type": "string",
"proposals": ["python", "/usr/local/python/bin/python"],
"default": "python",
"description": "Select or enter the python binary path."
} }
}, },
"extensions": [ "extensions": [
......
#!/usr/bin/env bash #!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
#
# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/jupyterlab.md
# Maintainer: The VS Code and Codespaces Teams
#
# Syntax: ./jupyter-debian.sh
set -e set -e
VERSION=${1:-"latest"} VERSION=${1:-"latest"}
USERNAME=${2:-"automatic"} USERNAME=${2:-"automatic"}
PYTHON=${3:-"python"}
ALLOW_ORIGIN=${4:-""}
# If in automatic mode, determine if a user already exists, if not use vscode # If in automatic mode, determine if a user already exists, if not use vscode
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
...@@ -24,9 +35,8 @@ elif [ "${USERNAME}" = "none" ]; then ...@@ -24,9 +35,8 @@ elif [ "${USERNAME}" = "none" ]; then
USER_GID=0 USER_GID=0
fi fi
# Use sudo to run as non-root user is not already running # Make sure we run the command as non-root user
sudoUserIf() sudoUserIf() {
{
if [ "$(id -u)" -eq 0 ] && [ "${USERNAME}" != "root" ]; then if [ "$(id -u)" -eq 0 ] && [ "${USERNAME}" != "root" ]; then
sudo -u ${USERNAME} "$@" sudo -u ${USERNAME} "$@"
else else
...@@ -34,18 +44,32 @@ sudoUserIf() ...@@ -34,18 +44,32 @@ sudoUserIf()
fi fi
} }
# If we don't yet have Python, install it now. addToJupyterConfig() {
if ! python --version > /dev/null ; then JUPYTER_DIR="/home/${USERNAME}/.jupyter"
JUPYTER_CONFIG="${JUPYTER_DIR}/jupyter_notebook_config.py"
# Make sure the config file exists
test -d ${JUPYTER_DIR} || sudoUserIf mkdir ${JUPYTER_DIR}
test -f ${JUPYTER_CONFIG} || sudoUserIf touch ${JUPYTER_CONFIG}
# Don't write the same line more than once
grep -q ${1} ${JUPYTER_CONFIG} || echo ${1} >> ${JUPYTER_CONFIG}
}
# Make sure that Python is available
if ! ${PYTHON} --version > /dev/null ; then
echo "You need to install Python before installing JupyterLab." echo "You need to install Python before installing JupyterLab."
exit 1 exit 1
fi fi
# If we don't already have JupyterLab installed, install it now. # pip skips installation if JupyterLab is already installed
if ! jupyter-lab --version > /dev/null ; then echo "Installing JupyterLab..."
echo "Installing JupyterLab..." if [ "${VERSION}" = "latest" ]; then
if [ "${VERSION}" = "latest" ]; then sudoUserIf ${PYTHON} -m pip install jupyterlab --no-cache-dir
pip install jupyterlab else
else sudoUserIf ${PYTHON} -m pip install jupyterlab=="${VERSION}" --no-cache-dir
pip install jupyterlab=="${VERSION}" --no-cache-dir fi
fi
if [ "${ALLOW_ORIGIN}" = 'true' ]; then
addToJupyterConfig "c.ServerApp.allow_origin = '*'"
fi fi
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
"default": false, "default": false,
"description": "Optimize Python for performance when compiled (slow)" "description": "Optimize Python for performance when compiled (slow)"
}, },
"install_path": { "installPath": {
"type": "string", "type": "string",
"default": "/usr/local/python", "default": "/usr/local/python",
"description": "The path where python will be installed." "description": "The path where python will be installed."
......
...@@ -10,7 +10,7 @@ _BUILD_ARG_AWS_CLI="./aws-cli/install.sh ${_B ...@@ -10,7 +10,7 @@ _BUILD_ARG_AWS_CLI="./aws-cli/install.sh ${_B
_BUILD_ARG_AZURE_CLI="./az-cli/install.sh ${_BUILD_ARG_AZURE_CLI_VERSION:-latest}" _BUILD_ARG_AZURE_CLI="./az-cli/install.sh ${_BUILD_ARG_AZURE_CLI_VERSION:-latest}"
_BUILD_ARG_SSH="./sshd/install.sh" _BUILD_ARG_SSH="./sshd/install.sh"
_BUILD_ARG_NODE="./node/install.sh /usr/local/share/nvm ${_BUILD_ARG_NODE_VERSION:-lts/*} automatic true ${_BUILD_ARG_NODE_NODEGYPDEPENDENCIES:-true}" _BUILD_ARG_NODE="./node/install.sh /usr/local/share/nvm ${_BUILD_ARG_NODE_VERSION:-lts/*} automatic true ${_BUILD_ARG_NODE_NODEGYPDEPENDENCIES:-true}"
_BUILD_ARG_PYTHON="./python/install.sh ${_BUILD_ARG_PYTHON_VERSION:-latest} /usr/local/python /usr/local/py-utils automatic true ${_BUILD_ARG_PYTHON_INSTALLTOOLS:-true} true ${_BUILD_ARG_PYTHON_OPTIMIZE:-false}" _BUILD_ARG_PYTHON="./python/install.sh ${_BUILD_ARG_PYTHON_VERSION:-latest} ${_BUILD_ARG_PYTHON_INSTALLPATH:-/usr/local/python} /usr/local/py-utils automatic true ${_BUILD_ARG_PYTHON_INSTALLTOOLS:-true} true ${_BUILD_ARG_PYTHON_OPTIMIZE:-false}"
_BUILD_ARG_GOLANG="./go/install.sh ${_BUILD_ARG_GOLANG_VERSION:-latest}" _BUILD_ARG_GOLANG="./go/install.sh ${_BUILD_ARG_GOLANG_VERSION:-latest}"
_BUILD_ARG_JAVA="./java/wrapper.sh ${_BUILD_ARG_JAVA_VERSION:-latest}" _BUILD_ARG_JAVA="./java/wrapper.sh ${_BUILD_ARG_JAVA_VERSION:-latest}"
_BUILD_ARG_GRADLE="./gradle/install.sh ${_BUILD_ARG_GRADLE_VERSION:-latest}" _BUILD_ARG_GRADLE="./gradle/install.sh ${_BUILD_ARG_GRADLE_VERSION:-latest}"
...@@ -20,4 +20,4 @@ _BUILD_ARG_RUST="./rust/install.sh /usr ...@@ -20,4 +20,4 @@ _BUILD_ARG_RUST="./rust/install.sh /usr
_BUILD_ARG_POWERSHELL="./powershell/install.sh ${_BUILD_ARG_POWERSHELL_VERSION:-latest}" _BUILD_ARG_POWERSHELL="./powershell/install.sh ${_BUILD_ARG_POWERSHELL_VERSION:-latest}"
_BUILD_ARG_DESKTOP_LITE="./desktop-lite/install.sh automatic ${_BUILD_ARG_DESKTOP_LITE_PASSWORD:-vscode} true ${_BUILD_ARG_DESKTOP_LITE_VNCPORT:-5901} ${_BUILD_ARG_DESKTOP_LITE_WEBPORT:-6080}" _BUILD_ARG_DESKTOP_LITE="./desktop-lite/install.sh automatic ${_BUILD_ARG_DESKTOP_LITE_PASSWORD:-vscode} true ${_BUILD_ARG_DESKTOP_LITE_VNCPORT:-5901} ${_BUILD_ARG_DESKTOP_LITE_WEBPORT:-6080}"
_BUILD_ARG_DOTNET="./dotnet/install.sh ${_BUILD_ARG_DOTNET_VERSION:-latest} ${_BUILD_ARG_DOTNET_RUNTIMEONLY:-false} automatic true /usr/local/dotnet dotnet" _BUILD_ARG_DOTNET="./dotnet/install.sh ${_BUILD_ARG_DOTNET_VERSION:-latest} ${_BUILD_ARG_DOTNET_RUNTIMEONLY:-false} automatic true /usr/local/dotnet dotnet"
_BUILD_ARG_JUPYTERLAB="./jupyterlab/install.sh ${_BUILD_ARG_JUPYTERLAB_VERSION:-latest}" _BUILD_ARG_JUPYTERLAB="./jupyterlab/install.sh ${_BUILD_ARG_JUPYTERLAB_VERSION:-latest}" automatic ${_BUILD_ARG_JUPYTERLAB_PYTHONBINARY:-python}" true
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment