Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable jupyter labextension build/watch to work for custom jupyterlab distributions #9697

Merged
merged 3 commits into from Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions jupyterlab/federated_labextensions.py
Expand Up @@ -163,9 +163,10 @@ def develop_labextension_py(module, user=False, sys_prefix=False, overwrite=True
return full_dests


def build_labextension(path, logger=None, development=False, static_url=None, source_map = False):
def build_labextension(path, logger=None, development=False, static_url=None, source_map = False, core_path=None):
"""Build a labextension in the given path"""
core_path = osp.join(HERE, 'staging')
if core_path is None:
core_path = osp.join(HERE, 'staging')
ext_path = osp.abspath(path)

if logger:
Expand All @@ -184,9 +185,10 @@ def build_labextension(path, logger=None, development=False, static_url=None, so
subprocess.check_call(arguments, cwd=ext_path)


def watch_labextension(path, labextensions_path, logger=None, development=False, source_map=False):
def watch_labextension(path, labextensions_path, logger=None, development=False, source_map=False, core_path=None):
"""Watch a labextension in a given path"""
core_path = osp.join(HERE, 'staging')
if core_path is None:
core_path = osp.join(HERE, 'staging')
ext_path = osp.abspath(path)

if logger:
Expand Down
20 changes: 15 additions & 5 deletions jupyterlab/labextensions.py
Expand Up @@ -87,6 +87,7 @@

VERSION = get_app_version()

HERE = os.path.abspath(os.path.dirname(__file__))

class BaseExtensionApp(JupyterApp, DebugLogFileMixin):
version = VERSION
Expand Down Expand Up @@ -211,15 +212,20 @@ class BuildLabExtensionApp(BaseExtensionApp):
source_map = Bool(False, config=True,
help="Generage source maps")

core_path = Unicode(os.path.join(HERE, 'staging'), config=True,
help="Directory containing core application package.json file")

aliases = {
'static-url': 'BuildLabExtensionApp.static_url',
'development': 'BuildLabExtensionApp.development',
'source-map': 'BuildLabExtensionApp.source_map'
'source-map': 'BuildLabExtensionApp.source_map',
'core-path': 'BuildLabExtensionApp.core_path'
}

def run_task(self):
self.extra_args = self.extra_args or [os.getcwd()]
build_labextension(self.extra_args[0], logger=self.log, development=self.development, static_url=self.static_url or None, source_map = self.source_map)
build_labextension(self.extra_args[0], logger=self.log, development=self.development, static_url=self.static_url or None, source_map = self.source_map,
core_path = self.core_path or None)


class WatchLabExtensionApp(BaseExtensionApp):
Expand All @@ -231,15 +237,19 @@ class WatchLabExtensionApp(BaseExtensionApp):
source_map = Bool(False, config=True,
help="Generage source maps")

core_path = Unicode(os.path.join(HERE, 'staging'), config=True,
help="Directory containing core application package.json file")

aliases = {
'development': 'BuildLabExtensionApp.development',
'source-map': 'BuildLabExtensionApp.source_map'

'source-map': 'BuildLabExtensionApp.source_map',
'core-path': 'BuildLabExtensionApp.core_path'
}
def run_task(self):
self.extra_args = self.extra_args or [os.getcwd()]
labextensions_path = self.labextensions_path
watch_labextension(self.extra_args[0], labextensions_path, logger=self.log, development=self.development, source_map=self.source_map)
watch_labextension(self.extra_args[0], labextensions_path, logger=self.log, development=self.development, source_map=self.source_map,
core_path = self.core_path or None)


class UpdateLabExtensionApp(BaseExtensionApp):
Expand Down