jupyterlab/federated_labextensions.py
def _get_labextension_metadata(module):
    """Get the list of labextension paths associated with a Python module.

    Returns a tuple of (the module path,             [{
        'src': 'mockextension',
        'dest': '_mockdestination'
    }])

    Parameters
    ----------

    module : str
        Importable Python module exposing the
        magic-named `_jupyter_labextension_paths` function
    """
    try:
        m = importlib.import_module(module)
    except Exception:
        m = None

    if not hasattr(m, '_jupyter_labextension_paths'):
        mod_path = osp.abspath(module)
        if osp.exists(mod_path):

            # Try getting the package name from setup.py
            try:
                package = subprocess.check_output([sys.executable, 'setup.py', '--name'], cwd=mod_path).decode('utf8').strip()
            except subprocess.CalledProcessError:
                from setuptools import find_packages
                package = find_packages(mod_path)[0]

            # Replace hyphens with underscores to match Python convention
            package = package.replace('-', '_')

            # Make sure the package is installed
            import pkg_resources
            try:
                dist = pkg_resources.get_distribution(package)
            except pkg_resources.DistributionNotFound:
                subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-e', mod_path])
                sys.path.insert(0, mod_path)

            m = importlib.import_module(package)

    if not hasattr(m, '_jupyter_labextension_paths'):
        raise KeyError('The Python module {} is not a valid labextension, '
                       'it is missing the `_jupyter_labextension_paths()` method.'.format(module))
    labexts = m._jupyter_labextension_paths()
    return m, labexts
Get the list of labextension paths associated with a Python module.

    Returns a tuple of (the module path,             [{
        'src': 'mockextension',
        'dest': '_mockdestination'
    }])

    Parameters
    ----------

    module : str
        Importable Python module exposing the
        magic-named `_jupyter_labextension_paths` function
    
Get the list of labextension paths associated with a Python module.

Parameters

module : str
Importable Python module exposing the
magic-named `_jupyter_labextension_paths` function
Get the list of labextension paths associated with a Python module . Parameters module : str Importable Python module exposing the magic - named ` _jupyter_labextension_paths ` function
def _get_labextension_metadata(module):
    try:
        m = importlib.import_module(module)
    except Exception:
        m = None
    if not hasattr(m, '_jupyter_labextension_paths'):
        mod_path = osp.abspath(module)
        if osp.exists(mod_path):
            try:
                package = subprocess.check_output([sys.executable, 'setup.py', '--name'], cwd=mod_path).decode('utf8').strip()
            except subprocess.CalledProcessError:
                from setuptools import find_packages
                package = find_packages(mod_path)[0]
            package = package.replace('-', '_')
            import pkg_resources
            try:
                dist = pkg_resources.get_distribution(package)
            except pkg_resources.DistributionNotFound:
                subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-e', mod_path])
                sys.path.insert(0, mod_path)
            m = importlib.import_module(package)
    if not hasattr(m, '_jupyter_labextension_paths'):
        raise KeyError('The Python module {} is not a valid labextension, '
                       'it is missing the `_jupyter_labextension_paths()` method.'.format(module))
    labexts = m._jupyter_labextension_paths()
    return m, labexts
def _get_labextension_metadata ( module ) : try : m = importlib . import_module ( module ) except Exception : m = None if not hasattr ( m , '_jupyter_labextension_paths' ) : mod_path = osp . abspath ( module ) if osp . exists ( mod_path ) : try : package = subprocess . check_output ( [ sys . executable , 'setup.py' , '--name' ] , cwd = mod_path ) . decode ( 'utf8' ) . strip ( ) except subprocess . CalledProcessError : from setuptools import find_packages package = find_packages ( mod_path ) [ 0 ] package = package . replace ( '-' , '_' ) import pkg_resources try : dist = pkg_resources . get_distribution ( package ) except pkg_resources . DistributionNotFound : subprocess . check_call ( [ sys . executable , '-m' , 'pip' , 'install' , '-e' , mod_path ] ) sys . path . insert ( 0 , mod_path ) m = importlib . import_module ( package ) if not hasattr ( m , '_jupyter_labextension_paths' ) : raise KeyError ( 'The Python module {} is not a valid labextension, ' 'it is missing the `_jupyter_labextension_paths()` method.' . format ( module ) ) labexts = m . _jupyter_labextension_paths ( ) return m , labexts
Get the list of labextension paths associated with a Python module.
Get the list of labextension paths associated with a Python module .
"""Get the list of labextension paths associated with a Python module.

    Returns a tuple of (the module path,             [{
        'src': 'mockextension',
        'dest': '_mockdestination'
    }])

    Parameters
    ----------

    module : str
        Importable Python module exposing the
        magic-named `_jupyter_labextension_paths` function
    """ # Try getting the package name from setup.py # Replace hyphens with underscores to match Python convention # Make sure the package is installed
module