
    $TXg                        d Z ddlmZ ddlZddlmZ ddlmZmZm	Z	 ddl
mZ  ee      Zd Zd	 Zd
 ZddZd Z ej&                  d      ZddZd Zy)z&Common Python specific path utilities.    )annotationsN)	getLogger)joinsplitsplitext   )on_winc                    |j                  dd      }|j                  d      r| dz   S t        |       \  }}t        |      \  }}d| d| | dz   }|rdj	                  |d|      S |S )	a	  
    This must not return backslashes on Windows as that will break
    tests and leads to an eventual need to make url_to_path return
    backslashes too and that may end up changing files on disc or
    to the result of comparisons with the contents of them.
    . 2cz__pycache__/z	.cpython-z{}{}{}/)replace
startswithr   r   format)py_pathpython_major_minor_versionpyver_string	directorypy_filebasename_root	extensionpyc_files           8lib/python3.12/site-packages/conda/common/path/python.pypyc_pathr      s     .55c2>Ls#}"7^	7#+G#4 y]O9\N9+UV"WW 	 =Fxy#x8S8S    c                Z     d D        } fd|D        }t        fd|D              }|S )Nc              3  D   K   | ]  }|j                  d       s|  yw)z.pyN)endswith).0fs     r   	<genexpr>z$missing_pyc_files.<locals>.<genexpr>%   s     65aAJJu$55s     c              3  :   K   | ]  }|t        |      f  y wN)r   )r!   r   r   s     r   r#   z$missing_pyc_files.<locals>.<genexpr>&   s#      PXW(7$>?@PXs   c              3  2   K   | ]  }|d    vs|  yw)   N )r!   matchfiless     r   r#   z$missing_pyc_files.<locals>.<genexpr>)   s     KkUU1XU5J5ks   )tuple)r   r*   py_filespyc_matchesresults   ``   r   missing_pyc_filesr/   #   s3    656HPXK KkKKFMr   c                    | j                  dd      \  }}|j                  dd      \  }}|j                         |j                         |j                         }}}|||fS )N:r'   =)rsplitstrip)ep_definitioncmd_modfunccommandmodules        r   parse_entry_point_defr:   -   sX    !((a0MGTnnS!,OGV#MMOV\\^TZZ\TVGFD  r   c                d    t         ry| rd| vrdj                  |       } t        dd| xs dz        S )Nz
python.exer   binzpython%sr   )r	   r   )python_versions    r   get_python_short_pathr>   4   s7    #^3.1z^%9r:;;r   c                8    | y t         ryt        |       }d| dS )NzLib/site-packages
lib/pythonz/site-packages)r	   get_major_minor_version)r=   py_vers     r   #get_python_site_packages_short_pathrC   <   s*    	"(8F8>22r   z[0-9]+\.[0-9]+c                   t        | t              sJ | j                  d      r?| j                  d      d   }t	        d      }t	        |      |dz   k  ry ||   ||dz   d  f}n| j                  d      rL| j                  d      d   }t	        d      }t	        |      |dz   k  ry ||dz      dk(  sJ ||   ||dz   d  f}nt
        j                  |       }|r+|j                  d	      j                  d      }|d	   |d   f}nId
j                  | D cg c]  }|j                         s| c}      }t	        |      dk  ry |d	   |dd  f}|rdj                  |      S d
j                  |      S c c}w )Nr@   r   r'   pythonr   z
bin/python   r   r   r   )

isinstancestrr   r   len_VERSION_REGEXr)   groupr   isdigit)	stringwith_dot	pythonstrstartmaj_minr)   versionr   digitss	            r   rA   rA   I   s    fc"""&LL%a(	Hy>EAI%E"Ieaik$::			<	(LL%a(	Hy>EAI%#s***E"Ieaik$::$$V,kk!n**3/Gaj'!*,GWW?A199;a?@F6{QQi+G (388G>bggg.>> @s   E/'E/c                    | j                  d      r|}| j                  d|d      S | j                  d      rddlm} | j                  d|d      S | S )Nzsite-packages/zsite-packagesr'   zpython-scripts/)BIN_DIRECTORYzpython-scripts)r   r   r   rU   )source_short_pathtarget_site_packages_short_pathsp_dirrU   s       r   get_python_noarch_target_pathrY   m   sY    ##$450 ((&!DD		%	%&7	8# (()9=!LL  r   r%   )T)__doc__
__future__r   reloggingr   os.pathr   r   r   compatr	   __name__logr   r/   r:   r>   rC   compilerJ   rA   rY   r(   r   r   <module>rc      s^    - " 	  ) ) T&!<3 -.!?H	!r   