remove SYSTEM_NBEXTENSIONS_DIRS

use SYSTEM_JUPYTER_PATH from core

for common logic with kernelspec installation
Min RK 11 years ago
parent 4dcd67a0de
commit 7706b6832d

@ -20,7 +20,7 @@ except ImportError:
from urlparse import urlparse
from urllib import urlretrieve
from jupyter_core.paths import jupyter_data_dir
from jupyter_core.paths import jupyter_data_dir, jupyter_path, SYSTEM_JUPYTER_PATH
from ipython_genutils.path import ensure_dir_exists
from ipython_genutils.py3compat import string_types, cast_unicode_py2
from ipython_genutils.tempdir import TemporaryDirectory
@ -28,33 +28,6 @@ from ipython_genutils.tempdir import TemporaryDirectory
class ArgumentConflict(ValueError):
pass
# Packagers: modify the next block if you store system-installed nbextensions elsewhere (unlikely)
SYSTEM_NBEXTENSIONS_DIRS = []
if os.name == 'nt':
programdata = os.environ.get('PROGRAMDATA', None)
if programdata: # PROGRAMDATA is not defined by default on XP.
SYSTEM_NBEXTENSIONS_DIRS = [pjoin(programdata, 'jupyter', 'nbextensions')]
prefixes = []
else:
prefixes = [os.path.sep + pjoin('usr', 'local'), os.path.sep + 'usr']
# add sys.prefix at the front
if sys.prefix not in prefixes:
prefixes.insert(0, sys.prefix)
for prefix in prefixes:
nbext = pjoin(prefix, 'share', 'jupyter', 'nbextensions')
if nbext not in SYSTEM_NBEXTENSIONS_DIRS:
SYSTEM_NBEXTENSIONS_DIRS.append(nbext)
if os.name == 'nt':
# PROGRAMDATA
SYSTEM_NBEXTENSIONS_INSTALL_DIR = SYSTEM_NBEXTENSIONS_DIRS[-1]
else:
# /usr/local
SYSTEM_NBEXTENSIONS_INSTALL_DIR = SYSTEM_NBEXTENSIONS_DIRS[-2]
def _should_copy(src, dest, verbose=1):
"""should a file be copied?"""
@ -98,7 +71,7 @@ def _get_nbext_dir(nbextensions_dir=None, user=False, prefix=None):
elif nbextensions_dir:
nbext = nbextensions_dir
else:
nbext = SYSTEM_NBEXTENSIONS_INSTALL_DIR
nbext = pjoin(SYSTEM_JUPYTER_PATH[0], 'nbextensions')
return nbext
@ -330,7 +303,7 @@ class NBExtensionApp(JupyterApp):
def start(self):
if not self.extra_args:
for nbext in [pjoin(self.data_dir, u'nbextensions')] + SYSTEM_NBEXTENSIONS_DIRS:
for nbext in jupyter_path('nbextensions'):
if os.path.exists(nbext):
print("Notebook extensions in %s:" % nbext)
for ext in os.listdir(nbext):

@ -81,12 +81,10 @@ from traitlets import (
TraitError, Type,
)
from ipython_genutils import py3compat
from ipython_genutils.path import filefind
from IPython.paths import get_ipython_dir
from jupyter_core.paths import jupyter_runtime_dir
from jupyter_core.paths import jupyter_runtime_dir, jupyter_path
from jupyter_notebook._sysinfo import get_sys_info
from .nbextensions import SYSTEM_NBEXTENSIONS_DIRS
from .utils import url_path_join, check_pid
#-----------------------------------------------------------------------------
@ -618,11 +616,10 @@ class NotebookApp(JupyterApp):
@property
def nbextensions_path(self):
"""The path to look for Javascript notebook extensions"""
return self.extra_nbextensions_path + [
os.path.join(self.data_dir, 'nbextensions'),
# FIXME: remove IPython nbextensions path once migration is setup
os.path.join(get_ipython_dir(), 'nbextensions'),
] + SYSTEM_NBEXTENSIONS_DIRS
path = self.extra_nbextensions_path + jupyter_path('nbextensions')
# FIXME: remove IPython nbextensions path once migration is setup
path.append(os.path.join(get_ipython_dir(), 'nbextensions'))
return path
websocket_url = Unicode("", config=True,
help="""The base URL for websockets,

@ -64,9 +64,10 @@ class TestInstallNBExtension(TestCase):
self.patch_data = patch.object(nbextensions,
'jupyter_data_dir', lambda : self.data_dir)
self.patch_data.start()
self.system_nbext = self.tempdir()
self.system_path = [self.tempdir()]
self.system_nbext = pjoin(self.system_path[0], 'nbextensions')
self.patch_system_data = patch.object(nbextensions,
'SYSTEM_NBEXTENSIONS_INSTALL_DIR', self.system_nbext)
'SYSTEM_JUPYTER_PATH', self.system_path)
self.patch_system_data.start()
def tearDown(self):
@ -123,12 +124,13 @@ class TestInstallNBExtension(TestCase):
def test_create_nbextensions_system(self):
with TemporaryDirectory() as td:
nbextensions.SYSTEM_NBEXTENSIONS_INSTALL_DIR = self.system_nbext = pjoin(td, u'nbextensions')
install_nbextension(self.src, user=False)
self.assert_installed(
pjoin(basename(self.src), u'ƒile'),
user=False
)
self.system_nbext = pjoin(td, u'nbextensions')
with patch.object(nbextensions, 'SYSTEM_JUPYTER_PATH', [td]):
install_nbextension(self.src, user=False)
self.assert_installed(
pjoin(basename(self.src), u'ƒile'),
user=False
)
def test_single_file(self):
file = self.files[0]

Loading…
Cancel
Save