U
    /el                     @  sd   d Z ddlmZ ddlZeeZddlmZ ddl	m
Z
 dZddd	d
dZddddddZdS )z& Utilities for checking dependencies

    )annotationsN)import_module)
ModuleType)import_optionalimport_requiredstrzModuleType | None)mod_namereturnc                 C  sL   z
t | W S  tk
r   Y n* tk
rF   d|  d}t| Y nX dS )a   Attempt to import an optional dependency.

    Silently returns None if the requested module is not available.

    Args:
        mod_name (str) : name of the optional module to try to import

    Returns:
        imported module or None, if import fails

    z"Failed to import optional module ``N)r   ImportError	Exceptionlog	exception)r   msg r   ;/tmp/pip-unpacked-wheel-f5fndrjf/bokeh/util/dependencies.pyr   (   s    
r   r   )r   	error_msgr	   c              
   C  s<   z
t | W S  tk
r6 } zt||W 5 d}~X Y nX dS )aY   Attempt to import a required dependency.

    Raises a RuntimeError if the requested module is not available.

    Args:
        mod_name (str) : name of the required module to try to import
        error_msg (str) : error message to raise when the module is missing

    Returns:
        imported module

    Raises:
        RuntimeError

    N)r   r   RuntimeError)r   r   er   r   r   r   ?   s    
r   )__doc__
__future__r   logging	getLogger__name__r   	importlibr   typesr   __all__r   r   r   r   r   r   <module>   s   
	