diff --git a/jupyter_vscode_proxy/__init__.py b/jupyter_vscode_proxy/__init__.py index eaed7be..686f443 100644 --- a/jupyter_vscode_proxy/__init__.py +++ b/jupyter_vscode_proxy/__init__.py @@ -4,31 +4,41 @@ def setup_vscode(): def _get_vscode_cmd(port): - executable = 'code-server' + executable = "code-server" if not shutil.which(executable): - raise FileNotFoundError('Can not find code-server in PATH') + raise FileNotFoundError("Can not find code-server in PATH") working_dir = os.getenv("CODE_WORKINGDIR", None) if working_dir is None: working_dir = os.getenv("REPO_DIR", ".") + extensions_dir = os.getenv("CODE_EXTENSIONSDIR", None) + extra_extensions_dir = os.getenv("CODE_EXTRA_EXTENSIONSDIR", None) + cmd = [ executable, - '--no-auth', - '--disable-telemetry', - '--allow-http', - '--port=' + str(port), - working_dir + "--auth", + "none", + "--disable-telemetry", + "--port=" + str(port), ] + + if extensions_dir: + cmd += ["--extensions-dir", extensions_dir] + + if extra_extensions_dir: + cmd += ["--extra-extensions-dir", extra_extensions_dir] + + cmd.append(working_dir) return cmd return { - 'command': _get_vscode_cmd, - 'timeout': 20, - 'launcher_entry': { - 'title': 'VS Code', - 'icon_path': os.path.join(os.path.dirname(os.path.abspath(__file__)), - 'icons', - 'vscode.svg') - } + "command": _get_vscode_cmd, + "timeout": 20, + "launcher_entry": { + "title": "VS Code", + "icon_path": os.path.join( + os.path.dirname(os.path.abspath(__file__)), "icons", "vscode.svg" + ), + }, } diff --git a/postBuild b/postBuild index c655544..9602dd1 100644 --- a/postBuild +++ b/postBuild @@ -1,12 +1,14 @@ #!/bin/bash +CODE_SERVER_VERSION="2.1692-vsc1.39.2" + # Enable the proxy extension in notebook and lab jupyter serverextension enable --py jupyter_server_proxy jupyter labextension install jupyterlab-server-proxy jupyter lab build # Download and install VS Code server -wget -q -O code-server.tar.gz https://github.com/cdr/code-server/releases/download/2.1523-vsc1.38.1/code-server2.1523-vsc1.38.1-linux-x86_64.tar.gz +wget -q -O code-server.tar.gz https://github.com/cdr/code-server/releases/download/${CODE_SERVER_VERSION}/code-server${CODE_SERVER_VERSION}-linux-x86_64.tar.gz mkdir -p ~/.local/bin tar -xvf code-server.tar.gz -C ~/.local/bin --strip-components=1 rm -rf code-server.tar.gz diff --git a/setup.py b/setup.py index 727242e..ba324b2 100644 --- a/setup.py +++ b/setup.py @@ -2,22 +2,18 @@ setuptools.setup( name="jupyter-vscode-proxy", - version='0.1', + version="0.1", url="https://github.com/betatim/vscode-binder", author="Tim Head", description="Jupyter extension to proxy VS Code", packages=setuptools.find_packages(), - keywords=['Jupyter'], - classifiers=['Framework :: Jupyter'], + keywords=["Jupyter"], + classifiers=["Framework :: Jupyter"], install_requires=[ #'jupyter-server-proxy' ], entry_points={ - 'jupyter_serverproxy_servers': [ - 'vscode = jupyter_vscode_proxy:setup_vscode', - ] - }, - package_data={ - 'jupyter_vscode_proxy': ['icons/*'], + "jupyter_serverproxy_servers": ["vscode = jupyter_vscode_proxy:setup_vscode",] }, + package_data={"jupyter_vscode_proxy": ["icons/*"],}, )