
    Q3j"                     @   d Z ddl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 ddd	d
ZdZdZdZdZdZdZd Zd Zd Zd Zej2                  j5                  deeg      d        Zej2                  j5                  dedfedfedfedfg      d        Zy)zCTests for the minimum dependencies in README.rst and pyproject.toml    N)defaultdict)Path)dependent_packages)parse_version)z1.3.0install)z1.10.0zbuild, install)z3.0.1maintenance)joblibscipyz
conda-lockz
[project]
dependencies = ["joblib>=1.3.0", "scipy>=1.10.0"]
[project.optional-dependencies]
build = ["scipy>=1.10.0"]
install = ["joblib>=1.3.0", "scipy>=1.10.0"]
maintenance = ["conda-lock==3.0.1"]
[build-system]
requires = ["scipy>=1.10.0"]
a  
[project]
dependencies = ["joblib>=1.3.0,<2.0", "scipy>=1.10.0"]
[project.optional-dependencies]
build = ["scipy>=1.10.0,<1.19.0"]
install = ["joblib>=1.3.0,<2.0", "scipy>=1.10.0"]
maintenance = ["conda-lock==3.0.1"]
[build-system]
requires = ["scipy>=1.10.0,<1.19.0"]
z
[project]
dependencies = ["scipy<1.10.0"]
[project.optional-dependencies]
build = ["scipy>=1.10.0"]
install = ["scipy>=1.10.0"]
maintenance = ["conda-lock==3.0.1"]
[build-system]
requires = ["scipy>=1.10.0"]
z
[project]
dependencies = ["scipy>=1.10.0"]
[project.optional-dependencies]
build = ["scipy>=1.10.0"]
install = ["scipy>=1.10.0"]
maintenance = ["conda-lock==3.0.1"]
[build-system]
requires = ["scipy>=1.10.0"]
a$  
[project]
dependencies = ["joblib>=1.3.0", "scipy>=1.10.0"]
[project.optional-dependencies]
build = ["scipy>=1.10.0", "package_not_in_min_dependencies_py_file>=4.2"]
install = ["joblib>=1.3.0", "scipy>=1.10.0"]
maintenance = ["conda-lock==3.0.1"]
[build-system]
requires = ["scipy>=1.10.0"]
z
[project]
dependencies = ["joblib>=1.42.0", "scipy>=1.10.0"]
[project.optional-dependencies]
build = ["scipy>=1.10.0"]
install = ["joblib>=1.3.0", "scipy>=1.10.0"]
maintenance = ["conda-lock==3.0.1"]
[build-system]
requires = ["scipy>=1.10.0"]
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   zK has inconsistent minimum versions in README.rst and _min_dependencies.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
             W/DATA/.local/lib/python3.12/site-packages/sklearn/tests/test_min_dependencies_readme.pytest_min_dependencies_readmer)   Z   s   
 jj	(G w''(//66K,K77>>+& 	;<			#	!DmmD)G&}}Q/q1AWGmmoG,,'0+,>w,G,JK i  ..5Yd;-I  +-6w6-#  
		s   AD$"/D$D$$D-c                     t        t              }| j                         D ]2  \  }\  }}|j                  d      D ]  }||   j	                  |        4 ddd}|D ]  }d| }|||<    ||fS )Nz, buildr   )build-system.requireszproject.dependencieszproject.optional-dependencies.)r   listitemssplitappend)	dependencies0min_dependencies_tag_to_packages_without_versionr$   r&   tagst)pyproject_section_to_min_dependencies_tagtagsections	            r(   #extract_packages_and_pyproject_tagsr8      s    7B47H4(4(:(:(<$$+tD!A<Q?FFwO " )=
 ") )1- @23%8=@1': @
 	91     c                 L   t        |      \  }}|j                         D ]  \  }}|dk(  rdgng }||   }|j                  d      }| }	|D ]  }
|	|
   }		 i }d}|	D ]R  }t        j                  ||      }|t        | d|d      |j                  d      |j                  d      }}|||<   T d	| d
}t        |      t        |      k(  sJ |       |j                         D ]<  \  }}t        |      }t        ||   d         }||v r'| d| d| }||k(  r7J |         y )Nr,   numpy.z([\w-]+)\s*[>=]=\s*([\d\w.]+)z does not match expected regex z7. Only >= and == are supported for version requirementsr   r   zPackages in z! differ from _min_dependencies.pyr   zO has inconsistent minimum versions in pyproject.toml and _min_dependencies.py: r   )	r8   r.   r/   r   searchNotImplementedErrorr   sortedr   )pyproject_tomlmin_dependenciespackagespyproject_tagspyproject_sectionmin_dependencies_tagskip_version_check_forexpected_packagespyproject_section_keysinfokeypyproject_build_min_versionsr   requirementr   r$   r%   msgexpected_min_versionr'   s                       r(   check_pyproject_sectionsrO      s   BCSTHn3A3G3G3I//
 +.EEWI2 	 %%9:!2!8!8!=)C9D * (*$2KIIg{3E})"m#B7+ NL L 
  %{{1~u{{1~WG4;(1   .//PQ23v>O7PPURUUP < B B DGW#G,G#01A'1J11M#N 00 ) **1$7K6LN  22;G;2 !EG 4Jr9   c                  H   t        t        j                        j                  j                  } | dz  }|j	                         st        j                  d       |j                  d      5 }t        j                  |      }ddd       t        t               y# 1 sw Y   xY w)zFCheck versions in pyproject.toml is consistent with _min_dependencies.zpyproject.tomlz pyproject.toml is not available.rbN)r   r   r   r   r   r   r   r   tomllibloadrO   r   )root_directorypyproject_toml_pathr!   r@   s       r(   $test_min_dependencies_pyproject_tomlrV      s     '**+2299N(+;;%%' 	67		!	!$	'1 a 
( ^-?@ 
(	's   )BB!example_pyprojectc                 N    t        j                  |       }t        |t               y)z-Test the version check for matching packages.N)rR   loadsrO   TOY_MIN_DEPENDENCIES_PY_INFO)rW   r@   s     r(   %test_check_matching_pyproject_sectionr[      s     ]]#45N^-IJr9   z)example_non_matching_pyproject, error_msgzZ.* does not match expected regex .*. Only >= and == are supported for version requirementsz/Packages in .* differ from _min_dependencies.pyzY.* has inconsistent minimum versions in pyproject.toml and _min_dependencies.py: .* != .*c                     t        j                  |       }t        j                  t        |      5  t        |t               ddd       y# 1 sw Y   yxY w)z>Test the version check for non-matching packages and versions.)r   N)rR   rY   r   raises	ExceptionrO   rZ   )example_non_matching_pyproject	error_msgr@   s      r(   )test_check_non_matching_pyproject_sectionra      s8    8 ]]#ABN	y		2 1MN 
3	2	2s   AA)__doc__r   r   rR   collectionsr   pathlibr   r   r   sklearn._min_dependenciesr   sklearn.utils.fixesr   rZ   TOY_MATCHING_PYPROJECT_SECTIONS0TOY_MATCHING_PYPROJECT_SECTIONS_WITH_UPPER_BOUND#TOY_WRONG_SYMBOL_PYPROJECT_SECTIONS&TOY_MISSING_PACKAGE_PYPROJECT_SECTIONS)TOY_ADDITIONAL_PACKAGE_PYPROJECT_SECTIONS+TOY_NON_MATCHING_VERSION_PYPROJECT_SECTIONSr)   r8   rO   rV   markparametrizer[   ra    r9   r(   <module>rp      s   I 	 	  #    8 -
 #)*  	# 	4 0	' #	* &	- )	/ +&7R(0<fA" '8KK / 0D	
 3=	

 6=	

 8.	
.O/.Or9   