U
    9%e                     @   sr   d Z ddlZddlZddl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 Zejjdd	d
d ZdS )zCTests for the minimum dependencies in README.rst and pyproject.toml    N)Path)dependent_packages)parse_versionc            	   	   C   s   t  dkrtd td} ttjd j	d }|d }t
j|sRtd |dt}|D ]h}| |}|svqb|d|d	 }}| }|tkrbt|}tt| d }||ksbt| d
qbW 5 Q R X d S )NPyPyz0PyPy does not always share the same minimum depszN(\.\. \|)(([A-Za-z]+\-?)+)(MinVersion\| replace::)( [0-9]+\.[0-9]+(\.[0-9]+)?)r   z
README.rstz%The README.rst file is not available.r       has a mismatched version)platformpython_implementationpytestskiprecompiler   sklearn__path__parentsospathexistsopenmatchgrouplowerr   r   AssertionError)	patternZreadme_pathZreadme_fileflineZmatchedpackageversionmin_version r!   i/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/sklearn/tests/test_min_dependencies_readme.pytest_min_dependencies_readme   s(    


r#   zFor the release purpose, the upper limit of Cython is set to 3.0 since it leads to performance regression. Scikit-learn can still be built with Cython 3.)reasonc               	   C   s   t d} ttjd j}|d }| s4t d |d}| 	|}W 5 Q R X |d d }i }|D ]*}d|krh|
d\}}	| }|	||< qhtd	d
gt|kst| D ]6\}}	t|	}	tt| d }
|	|
kst| dqdS )zFCheck versions in pyproject.toml is consistent with _min_dependencies.tomllibr   zpyproject.tomlz pyproject.toml is not available.rbzbuild-systemrequiresz>=Zscipycythonr	   N)r   Zimportorskipr   r   r   parentr   r   r   loadsplitr   setr   itemsr   r   )r%   Zroot_directorypyproject_toml_pathr   pyproject_tomlZbuild_requirementsZpyproject_build_min_versionsrequirementr   r   Zexpected_min_versionr!   r!   r"   $test_min_dependencies_pyproject_toml8   s&    



r1   )__doc__r   r
   r   pathlibr   r   r   Zsklearn._min_dependenciesr   Zsklearn.utils.fixesr   r#   markr   r1   r!   r!   r!   r"   <module>   s   (