Пример #1
0
def watch_labextension(
    path, labextensions_path, logger=None, development=False, source_map=False, core_path=None
):
    """Watch a labextension in a given path"""
    if core_path is None:
        core_path = osp.join(HERE, "staging")
    ext_path = osp.abspath(path)

    if logger:
        logger.info("Building extension in %s" % path)

    # Check to see if we need to create a symlink
    federated_extensions = get_federated_extensions(labextensions_path)

    with open(pjoin(ext_path, "package.json")) as fid:
        ext_data = json.load(fid)

    if ext_data["name"] not in federated_extensions:
        develop_labextension_py(ext_path, sys_prefix=True)
    else:
        full_dest = pjoin(federated_extensions[ext_data["name"]]["ext_dir"], ext_data["name"])
        output_dir = pjoin(ext_path, ext_data["jupyterlab"].get("outputDir", "static"))
        if not osp.islink(full_dest):
            shutil.rmtree(full_dest)
            os.symlink(output_dir, full_dest)

    builder = _ensure_builder(ext_path, core_path)
    arguments = ["node", builder, "--core-path", core_path, "--watch", ext_path]
    if development:
        arguments.append("--development")
    if source_map:
        arguments.append("--source-map")

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

    if logger:
        logger.info('Building extension in %s' % path)

    # Check to see if we need to create a symlink
    federated_extensions = get_federated_extensions(labextensions_path)

    with open(pjoin(ext_path, 'package.json')) as fid:
        ext_data = json.load(fid)

    if ext_data['name'] not in federated_extensions:
        develop_labextension_py(ext_path, sys_prefix=True)
    else:
        full_dest = pjoin(federated_extensions[ext_data['name']]['ext_dir'], ext_data['name'])
        output_dir = pjoin(ext_path, ext_data['jupyterlab'].get('outputDir', 'static'))
        if not osp.islink(full_dest):
            shutil.rmtree(full_dest)
            os.symlink(output_dir, full_dest)

    builder = _ensure_builder(ext_path, core_path)
    arguments = ['node', builder, '--core-path', core_path,  '--watch', ext_path]
    if development:
        arguments.append('--development')
    if source_map:
        arguments.append('--source-map')

    subprocess.check_call(arguments, cwd=ext_path)
Пример #3
0
    'jupyter-cytoscape',  # for ipycytoscape
    'jupyter-matplotlib',
    'jupyter-vuetify',
]


try:
    from jupyterlab.commands import check_extension, AppOptions
    from jupyterlab_server.config import get_federated_extensions
except ImportError:
    print(FIX_PREFIX, 'Please install jupyterlab before checking extensions.')
else:
    missing_extensions = []

    # Fetch federated extensions
    federated_extensions = get_federated_extensions([sys.base_prefix + '/share/jupyter/labextensions']).keys()

    # JupyterLab be quiet
    logger = logging.Logger('quiet')
    logger.setLevel(logging.CRITICAL)
    app_options = AppOptions(logger=logger)

    for extension in lab_extensions:
        if not check_extension(extension, app_options=app_options) and extension not in federated_extensions:
            missing_extensions.append(extension)

    if missing_extensions:
        print(FIX_PREFIX, 'These lab extensions are missing: ',
              ', '.join(missing_extensions))
        print(FIX_PREFIX,' Please try to install the following packages with conda or pip: ',
              ', '.join(missing_extensions))