
    ri                        d Z ddlZddlZddlmZ ddlmZ ddlZddlZddl	m
Z
 ddlmZ  ee      Z e
j                         D ]2  \  Z\  ZZej'                  d      D ]  Zee   j+                  e        4 dd	d
ZeD ]  Zde Zeee<    d Z	 ddZej6                  j9                  dej                               d        Zy)zCTests for the minimum dependencies in README.rst and pyproject.toml    N)defaultdict)Path)dependent_packages)parse_versionz, buildinstall)zbuild-system.requireszproject.dependencieszproject.optional-dependencies.c                  `   t        j                  d      } t        t        j                        j
                  j
                  }|dz  }t        j                  j                  |      st        j                  d       |j                  d      5 }|D ]  }| j                  |      }|s|j                  d      |j                  d      }}|j                         }|t        v sRt!        |      }t!        t        |   d         }| d| d	| }	||k(  rJ |	        	 d d d        y # 1 sw Y   y xY w)
NzE\.\. \|([A-Za-z-]+)MinVersion\| replace::( [0-9]+\.[0-9]+(\.[0-9]+)?)z
README.rstz%The README.rst file is not available.r      r   zH has inconsistent minimum versions in README.rst and _min_depencies.py:  != )recompiler   sklearn__file__parentospathexistspytestskipopenmatchgrouplowerr   r   )
patternreadme_pathreadme_fileflinematchedpackageversionmin_versionmessages
             h/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/sklearn/tests/test_min_dependencies_readme.pytest_min_dependencies_readmer'      s+   
 jj	(G w''(//66K,K77>>+& 	;<			#	 7! 	7DmmD)G&}}Q/q1AWGmmoG,,'0+,>w,G,JK i  ++2)4}F  +-6w6-#	77 7 7s   AD$"/D$D$$D-c                 0   t        j                  d      }|g }t        |   }t        t        j
                        j                  j                  }|dz  }|j                         st        j                  d       |j                  d      5 }|j                  |      }d d d        | j                  d      }	}
|	D ]  }|
|   }
	 i }d}|
D ]R  }t        j                  ||      }|t        | d|d      |j                  d	      |j                  d
      }}|||<   T t!        |      t!        |      k(  sJ |j#                         D ]@  \  }}t%        |      }t%        t&        |   d         }||v r+| d| d| }||k(  r;J |        y # 1 sw Y   xY w)Ntomllibzpyproject.tomlz pyproject.toml is not available.rb.z([\w-]+)\s*[>=]=\s*([\d\w.]+)z does not match expected regex z7. Only >= and == are supported for version requirementsr   r   r   zL has inconsistent minimum versions in pyproject.toml and _min_depencies.py: r   )r   importorskip-min_depencies_tag_to_packages_without_versionr   r   r   r   r   r   r   loadsplitr   searchNotImplementedErrorr   sorteditemsr   r   )pyproject_sectionmin_dependencies_tagskip_version_check_forr)   expected_packagesroot_directorypyproject_toml_pathr   pyproject_tomlpyproject_section_keysinfokeypyproject_build_min_versionsr   requirementr   r"   r#   expected_min_versionr%   s                       r&   check_pyproject_sectionrA   E   s    !!),G%!#E '**+2299N(+;;%%' 	67		!	!$	' )1 a) /44S9D% Cy $&  /G 
8		';/=%->wk JH H 
 !;;q>5;;q>07$W-
8 ./6:K3LLLL8>>@ 
8(,-?-H-KL,, i ##*)40D/EG 	 ..77.
87) )s   FFz'pyproject_section, min_dependencies_tagc                 4    |dk(  rdgnd}t        | ||       y)zFCheck versions in pyproject.toml is consistent with _min_dependencies.r   numpyN)r6   )rA   )r4   r5   r6   s      r&   $test_min_dependencies_pyproject_tomlrD      s&     +?'*IgYt5    )N)__doc__r   r   collectionsr   pathlibr   r   r   sklearn._min_dependenciesr   sklearn.utils.fixesr   listr-   r3   r"   r$   extrasr/   extraappend)pyproject_section_to_min_dependencies_tagtagsectionr'   rA   markparametrizerD    rE   r&   <module>rU      s    I 	 	 #    8 -0;D0A -&>&8&>&>&@ M"G"k6d# M5e<CCGLMM
 %%- ) 9 =C.se4G9<-g6=
&7T EI:8z --335			rE   