o
    i2                  
   @   s~   d dl mZ d dlmZmZ d dlmZmZ 	ddedede	dee	 fd	d
Z
dedee fddZdedede	fddZdS )    )Optional)InvalidSpecifierSpecifierSet)InvalidVersionVersionTversion
constraintprereleasesreturnc              	   C   sR   |d   rd| }z
t|}t| } W n ttfy!   Y dS w ||_| |v S )a  Check if a version (e.g. "2.0.0") is compatible given a version
    constraint (e.g. ">=1.9.0,<2.2.1"). If the constraint is a specific version,
    it's interpreted as =={version}.

    version (str): The version to check.
    constraint (str): The constraint string.
    prereleases (bool): Whether to allow prereleases. If set to False,
        prerelease versions will be considered incompatible.
    RETURNS (bool / None): Whether the version is compatible, or None if the
        version or constraint are invalid.
    r   z==N)isdigitr   r   r   r   r	   )r   r   r	   spec r   H/home/ubuntu/.local/lib/python3.10/site-packages/weasel/util/versions.pyis_compatible_version   s   
r   c              	   C   s8   zt | }W n ttfy   Y dS w |j d|j S )zGet the major + minor version (without patch or prerelease identifiers).

    version (str): The version.
    RETURNS (str): The major + minor version or None if version is invalid.
    N.)r   	TypeErrorr   majorminor)r   vr   r   r   get_minor_version!   s   r   	version_a	version_bc                 C   s(   t | }t |}|duo|duo||kS )aN  Compare two versions and check if they match in major and minor, without
    patch or prerelease identifiers. Used internally for compatibility checks
    that should be insensitive to patch releases.

    version_a (str): The first version
    version_b (str): The second version.
    RETURNS (bool): Whether the versions match.
    N)r   )r   r   abr   r   r   is_minor_version_match.   s   	r   N)T)typingr   packaging.specifiersr   r   packaging.versionr   r   strboolr   r   r   r   r   r   r   <module>   s    
