o
    ;i                     @   s   d dl Zd dlZd dlmZmZ d dlmZ ddlm	Z	 dd Z
g dZd	ed
ejeeef  fddZded
eeef fddZdS )    N)PackageNotFoundErrorfiles)Path   )ModuleNotMountablec                 C   sF   zt | }|s
g W S dd |D }tt|W S  ty"   g  Y S w )Nc                 S   s*   g | ]}d t |v rt |d d qS ).)strsplit).0p r   N/home/ubuntu/.local/lib/python3.10/site-packages/modal/_utils/package_utils.py
<listcomp>   s   * z$get_file_formats.<locals>.<listcomp>)r   listsetr   )modulemodule_filesendingsr   r   r   get_file_formats
   s   r   )soSsasmmodule_namereturnc              
   C   s   t | }ttt|@ rt|  dztj| }W n ty- } ztt|d}~ww g }|du r;t|  d|j	rGdd |j	D }n|j
}|dur[t| r[dt|fg}|sdt|  d|S )zQReturns a list of tuples [(is_dir, path)] describing how to mount a given module.z5 can't be mounted because it contains binary file(s).Nz& has no spec - might not be installed?c                 S   s$   g | ]}t | rd t |fqS )T)r   exists)r   pathr   r   r   r   '   s   $ z)get_module_mount_info.<locals>.<listcomp>Fz has no mountable paths)r   r   BINARY_FORMATSr   	importlibutil	find_spec	Exceptionr	   submodule_search_locationsoriginr   r   )r   file_formatsspecexcentriesfilenamer   r   r   get_module_mount_info   s(   r*   version_stringc                 C   sX   |  d}t|dk rtdzt|d }t|d }W ||fS  ty+   tdw )Nr   r   z1version_string must have at least an 'X.Y' formatr      zRversion_string must have at least an 'X.Y' format with integral major/minor values)r
   len
ValueErrorint)r+   partsmajorminorr   r   r   parse_major_minor_version2   s   
r3   )importlib.utilr   typingimportlib.metadatar   r   pathlibr   	exceptionr   r   r   r	   Sequencetupleboolr*   r/   r3   r   r   r   r   <module>   s    