o
    ٷi                     @  sL   d dl mZ d dlZd dlmZ d dlmZ d dlmZ dddddZ	dS )    )annotationsN)Callable)
ModuleType)DynamicLibNotFoundError)probe_functionfully_qualified_modnamestrr   %Callable[[ModuleType], object] | NonereturnModuleType | Nonec             
   C  sr   zt | }W n ty  } z|j| kr W Y d}~dS d}~ww |dur7z|| W |S  ty6   Y dS w |S )a#  Import an optional CUDA module without masking unrelated import bugs.

    Returns:
        The imported module if available and the optional probe succeeds,
        otherwise ``None`` when the requested module is unavailable.

    Raises:
        ModuleNotFoundError: If the import fails because a dependency of the
            target module is missing (instead of the target module itself).
        Exception: Any exception raised by ``probe_function`` except
            :class:`DynamicLibNotFoundError`, which is treated as "unavailable".
    N)	importlibimport_moduleModuleNotFoundErrornamer   )r   r   moduleerr r   Y/home/ubuntu/.local/lib/python3.10/site-packages/cuda/pathfinder/_optional_cuda_import.py_optional_cuda_import   s    

r   )r   r   r   r	   r
   r   )

__future__r   r   collections.abcr   typesr   ,cuda.pathfinder._dynamic_libs.load_dl_commonr   r   r   r   r   r   <module>   s   