
    0Ph                        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 ];\  Z\  ZZe                    d          D ]Zee                             e           <dd	d
ZeD ]
Zde ee<   d Z	 ddZej                            de                                          d             ZdS )zCTests for the minimum dependencies in README.rst and pyproject.toml    N)defaultdict)Path)dependent_packages)parse_versionz, zbuild-system.requireszproject.dependencies)buildinstallzproject.optional-dependencies.c                     t          j        d          } t          t          j                  j        j        }|dz  }t          j                            |          st          j
        d           |                    d          5 }|D ]}|                     |          }|s|                    d          |                    d          }}|                                }|t          v rBt!          |          }t!          t          |         d                   }||k    sJ | d            	 d d d            d S # 1 swxY w Y   d S )	NzN(\.\. \|)(([A-Za-z]+\-?)+)(MinVersion\| replace::)( [0-9]+\.[0-9]+(\.[0-9]+)?)z
README.rstz%The README.rst file is not available.r      r    has a mismatched version)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_versions	            j/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sklearn/tests/test_min_dependencies_readme.pytest_min_dependencies_readmer&      s   
 j	* G w'((/6K,K7>>+&& = 	;<<<			#		 U! 	U 	UDmmD))G &}}Q//q1A1AWGmmooG,,,'00+,>w,G,JKK+---'/T/T/T---	UU U U U U U U U U U U U U U U U U Us   B'D::D>D>c                 r   t          j        d          }|g }t          |         }t          t          j                  j        j        }|dz  }|                                st          j        d           |	                    d          5 }|
                    |          }d d d            n# 1 swxY w Y   |                     d          }	|}
|	D ]
}|
|         }
i }|
D ]S}d|v r|                    d          \  }}n/d|v r|                    d          \  }}nt          | d          |||<   Tt          |          t          |          k    sJ |                                D ]L\  }}t          |          }t          t           |         d	                   }||v r9||k    sJ | d
            Md S )Ntomllibzpyproject.tomlz pyproject.toml is not available.rb.z>=z==zV not supported yet in this test. Only >= and == are supported for version requirementsr   r   )r   importorskip-min_depencies_tag_to_packages_without_versionr   r   r   r   r   r   r   loadsplitNotImplementedError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_versionsrequirementr"   r#   expected_min_versions                    r%   check_pyproject_sectionr?   B   se    !),,G%!#E '*++29N(+;;%%'' 8 	6777		!	!$	'	' )1 a) ) ) ) ) ) ) ) ) ) ) ) ) ) ) /44S99D%  Cy#%  8 8;*0066GWW[  *0066GWW% H H H  
 18$W--.//6:K3L3LLLLL8>>@@ V V((,-?-H-KLL,,,....70U0U0U....V Vs   B--B14B1z'min_dependencies_tag, pyproject_sectionc                 @    |dk    rdgnd}t          | ||           dS )zFCheck versions in pyproject.toml is consistent with _min_dependencies.r   numpyN)r4   )r?   )r2   r3   r4   s      r%   $test_min_dependencies_pyproject_tomlrB   x   sD     +?'*I*IgYYt5         )N)__doc__r   r   collectionsr   pathlibr   r   r   sklearn._min_dependenciesr   sklearn.utils.fixesr   listr,   r1   r"   r$   extrasr.   extraappend)min_dependencies_tag_to_pyproject_sectiontagr&   r?   markparametrizerB    rC   r%   <module>rR      s   I I 				 				 # # # # # #         8 8 8 8 8 8 - - - - - -0;D0A0A -&>&8&>&@&@ M M"G"k6d## M M5e<CCGLLLLM %%- - ) 9  C... .c22
"U "U "UL EI3V 3V 3V 3Vl --3355 	 		 	 	 	rC   