Skip to content

Commit c11baa2

Browse files
authored
Merge pull request #31 from jcoady/master
VPython support on JupyterHub and Binder
2 parents ec99491 + 7b8a8c5 commit c11baa2

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
Cython
22
vpython
3-
jupyter-server-proxy

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import versioneer
2020

21-
install_requires = ['jupyter', 'numpy', 'ipykernel',
21+
install_requires = ['jupyter', 'jupyter-server-proxy', 'numpy', 'ipykernel',
2222
'autobahn>=18.8.2']
2323

2424
if sys.version_info.major == 3 and sys.version_info.minor >= 5:

vpython/with_notebook.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,15 @@ def find_free_port():
5858
if jupyterlab.__version__ >= '0.35.0':
5959
from os.path import join
6060
labextensions_dir = join(jupyterlab.commands.get_app_dir(), u'static')
61-
notebook.nbextensions.install_nbextension(path=package_dir + "/vpython_data",
62-
nbextensions_dir=labextensions_dir,
63-
overwrite=False,
64-
verbose=0)
61+
try:
62+
notebook.nbextensions.install_nbextension(path=package_dir + "/vpython_data",
63+
nbextensions_dir=labextensions_dir,
64+
overwrite=False,
65+
verbose=0)
66+
except PermissionError:
67+
#logging.info("PermissionError: Unable to install /vpython_data directory and files for VPython on JupyterLab")
68+
pass
69+
6570

6671
if 'nbextensions' in os.listdir(jd):
6772
ldir = os.listdir(nbdir)
@@ -101,7 +106,10 @@ def find_free_port():
101106
display(Javascript("""if (typeof Jupyter !== "undefined") {require(["nbextensions/vpython_libraries/glowcomm"], function(){console.log("GLOWCOMM LOADED");});}else{element.textContent = ' ';}"""))
102107
display(Javascript("""if (typeof Jupyter !== "undefined") {require(["nbextensions/vpython_libraries/jquery-ui.custom.min"], function(){console.log("JQUERY LOADED");});}else{element.textContent = ' ';}"""))
103108

104-
time.sleep(1) # allow some time for javascript code above to run before attempting to setup Comm Channel
109+
if transfer:
110+
time.sleep(4) # allow some time for javascript code above to run after nbextensions update before attempting to setup Comm Channel
111+
else:
112+
time.sleep(2) # allow some time for javascript code above to run before attempting to setup Comm Channel
105113

106114
wsConnected = False
107115

0 commit comments

Comments
 (0)