o
    Ù­ji  ã                   @   s\   d Z ddlZddlZddlZddlmZ G dd„ deƒZdefdd„Z	dee
 fd	d
„ZdS )z/Find the path to xgboost dynamic library files.é    N)ÚListc                   @   s   e Zd ZdZdS )ÚXGBoostLibraryNotFoundz)Error thrown by when xgboost is not foundN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   úL/var/www/html/CropPilot/venv/lib/python3.10/site-packages/xgboost/libpath.pyr   
   s    r   Úreturnc                   C   s   t tj dd¡ƒS )zP`XGBOOST_BUILD_DOC` is used by the sphinx conf.py to skip building the C++ code.ÚXGBOOST_BUILD_DOCF)ÚboolÚosÚenvironÚgetr   r   r   r	   Úis_sphinx_build   s   r   c                  C   s¢  t j t j t j t¡¡¡} t j | d¡t j | t jjt jjd¡t j tj	d¡g}tj
dkrs| t j tj	d¡t j tj	d¡t j tj	dd¡t j tj	dd¡t j tj	dd¡t j tj	ddd¡t j tj	ddd¡g¡ dd„ |D ƒ}n'tj
 d¡r�d	d„ |D ƒ}ntj
d
krŽdd„ |D ƒ}ntj
dkršdd„ |D ƒ}t
 ¡ dkr§dd„ |D ƒ}dd„ |D ƒ}|sÏtƒ sÏd}dd |¡ d |  d tj	 d | d }t|ƒ‚|S )z‹Find the path to xgboost dynamic library files.

    Returns
    -------
    lib_path
       List of all found library path to xgboost
    ÚlibÚwin32ÚbinÚLibraryz	mingw-w64c                 S   ó   g | ]	}t j |d ¡‘qS )zxgboost.dll©r   ÚpathÚjoin©Ú.0Úpr   r   r	   Ú
<listcomp>3   ó    z!find_lib_path.<locals>.<listcomp>)ÚlinuxÚfreebsdÚ
emscriptenc                 S   r   ©zlibxgboost.sor   r   r   r   r	   r   5   r   Údarwinc                 S   r   )zlibxgboost.dylibr   r   r   r   r	   r   7   r   Úcygwinc                 S   r   )zcygxgboost.dllr   r   r   r   r	   r   9   r   ÚOS400c                 S   r   r!   r   r   r   r   r	   r   ;   r   c                 S   s(   g | ]}t j |¡rt j |¡r|‘qS r   )r   r   ÚexistsÚisfiler   r   r   r	   r   =   s   ( z5https://xgboost.readthedocs.io/en/stable/install.htmlzJCannot find XGBoost Library in the candidate path.  List of candidates:
- z
- z
XGBoost Python package path: z
sys.base_prefix: z
See: z for installing XGBoost.)r   r   ÚdirnameÚabspathÚ
expanduserÚ__file__r   ÚpardirÚsysÚbase_prefixÚplatformÚextendÚ
startswithÚsystemr   r   )Ú	curr_pathÚdll_pathÚlib_pathÚlinkÚmsgr   r   r	   Úfind_lib_path   s`   ù

ùÿ


þýüûúùø	÷ÿr7   )r   r   r.   r,   Útypingr   Ú	Exceptionr   r   r   Ústrr7   r   r   r   r	   Ú<module>   s   