o
    JAf                     @   s   d dl Z d dlZd dl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
mZ ddlmZ ddlmZ ddlmZ d	d
 Zdd Zdd Zdd Zdd Zdd ZG dd deZdS )    N)log)DistutilsError)partial   )_reqs)Wheel)SetuptoolsDeprecationWarningc                 C   s(   t | tr	|  S t | ttfsJ | S )z8Ensure find-links option end-up being a list of strings.)
isinstancestrsplittuplelist)
find_links r   V/usr/lib/python3.10/site-packages/setuptools-67.5.1-py3.10.egg/setuptools/installer.py_fixup_find_links   s   
r   c                 C   s   t jdd t|  t| |S )zLFetch an egg needed for building.

    Use pip/wheel to fetch/build a wheel.   
stacklevel)_DeprecatedInstallerwarn_warn_wheel_not_available_fetch_build_egg_no_warn)distreqr   r   r   fetch_build_egg   s   
r   c                 C   s\   dd l }tjdd t|  |jjt||jt	t
| dd}|D ]
} |jj| dd q!|S )Nr      r   T)	installerreplace_conflicting)replace)pkg_resourcesr   r   r   working_setresolver   parseRequirementr   r   add)r   requiresr    Zresolved_distsr   r   r   _fetch_build_eggs!   s   r'   c                 C   s  dd l }t|}| d}d|v rtddtjvodtjv}dtjv r'd }nd|v r2|d d	 }nd }d
|v rDt|d
 d	 d d  ng }| jrO|| j tj	
|  }| }||D ]}	|	|v ro||	ro|	  S q`t }
tjdddddd|
g}|r|d |d ur|d|f |pg D ]	}|d|f q||jpt| zt| W n tjy } ztt||d }~ww tttj	|
dd }tj	|| }|| ||tj	|d}|jj ||d} | W  d    S 1 sw   Y  d S )Nr   easy_installallow_hostszQthe `allow-hosts` option is not supported when using pip to install requirements.Z	PIP_QUIETZPIP_VERBOSEZPIP_INDEX_URL	index_urlr   r   z-mZpipz--disable-pip-version-checkwheelz	--no-depsz-wz--quietz--index-urlz--find-linksz*.whlzEGG-INFO)metadata)!r    strip_markerget_option_dictr   osenvironr   dependency_linksextendpathrealpathget_egg_cache_dirEnvironmentfind_distributionscan_addtempfileTemporaryDirectorysys
executableappendurlr
   
subprocess
check_callCalledProcessErrorr   globjoinegg_nameinstall_as_eggPathMetadataDistributionfrom_filename)r   r   r    optsquietr*   r   Zeggs_direnvironmentZegg_disttmpdircmdlinker+   Zdist_locationZdist_metadatar   r   r   r   1   sh   

 


&r   c                 C   s"   ddl }|jt| } d| _| S )z
    Return a new requirement without the environment marker to avoid
    calling pip with something like `babel; extra == "i18n"`, which
    would always be ignored.
    r   N)r    r$   r#   r
   marker)r   r    r   r   r   r-   n   s   r-   c                 C   s>   dd l }z|d W d S  |jy   | dtj Y d S w )Nr   r+   z,WARNING: The wheel package is not available.)r    get_distributionDistributionNotFoundannouncer   WARN)r   r    r   r   r   r   |   s   r   c                   @   s   e Zd ZedddZdS )r   r   c                 C   s   t jd| |d d d S )Nzsetuptools.installer and fetch_build_eggs are deprecated. Requirements should be satisfied by a PEP 517 installer. If you are using pip, you can try `pip install --use-pep517`.r   r   )warningsr   )clsr   r   r   r   r      s
   
z_DeprecatedInstaller.warnN)r   )__name__
__module____qualname__classmethodr   r   r   r   r   r      s    r   )rB   r/   r?   r;   r9   rU   	distutilsr   distutils.errorsr   	functoolsr    r   r+   r   _deprecation_warningr   r   r   r'   r   r-   r   r   r   r   r   r   <module>   s&    	=	