o
    8)i                     @  sD   d Z ddlmZ dddZ	ddddZ	ddddZdddZdS )z9Compatibility utilities for cross-platform functionality.    )annotationspathstrreturnc                 C  s   |  ddS )a  Normalize path separators for cross-platform assertions.

    On Windows, this converts backslashes to forward slashes to ensure
    path comparisons work correctly. On other platforms, returns the path unchanged.
    The length of the string is not changed by this operation.

    Args:
        path: The path string to normalize

    Returns:
        The path with normalized separators
    \/)replace)r    r	   Q/home/app/PyTorch/.pytorch/lib/python3.10/site-packages/setuptools_scm/_compat.pynormalize_path_for_assertion   s   r   N	full_pathsuffix_path	error_msg
str | Nonec                 C  sP   t | }|r||sJ |n||sJ d| d|| dt|  S )a  Strip a suffix from a path, with cross-platform path separator handling.

    This function first normalizes path separators for Windows compatibility,
    then asserts that the full path ends with the suffix, and finally returns
    the path with the suffix removed. This is the common pattern used for
    computing parent directories from git output.

    Args:
        full_path: The full path string
        suffix_path: The suffix path to strip from the end
        error_msg: Optional custom error message for the assertion

    Returns:
        The prefix path with the suffix removed

    Raises:
        AssertionError: If the full path doesn't end with the suffix
    zPath assertion failed: z does not end with N)r   endswithlen)r   r   r   Znormalized_fullr	   r	   r
   strip_path_suffix   s   r   Nonec                 C  s   t | || dS )-Legacy alias - use strip_path_suffix instead.Nr   )r   r   r   r	   r	   r
   assert_path_endswith8   s   r   c                 C  s
   t | |S )r   r   )r   r   r	   r	   r
   compute_path_prefix?   s   
r   )r   r   r   r   )N)r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   )r   r   r   r   r   r   )__doc__
__future__r   r   r   r   r   r	   r	   r	   r
   <module>   s    
#