U ��.e,�@sdZddlZddlZddlmZddlmZddlmZddl m Z ddl m Z m Z mZmZmZddlmZdd lmZdd lmZdd lmZdd lmZmZdd lmZer�ddlmZddlm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(e�)e*�Z+dd�Z,Gdd�de-�Z.dS)z)Prepares a distribution for installation �N)�requests)�)make_distribution_for_install_requirement)�InstalledDistribution)� unpack_url)�DirectoryUrlHashUnsupported� HashUnpinned�InstallationError�PreviousBuildDirError�VcsHashUnsupported)� expanduser)� MissingHashes)� indent_log)�write_delete_marker_file)� display_path�normalize_path)�MYPY_CHECK_RUNNING)�Optional)�AbstractDistribution)� PackageFinder)� PipSession)�InstallRequirement)�RequirementTrackerc Cs.t|�}|�|��|�||�W5QRX|S)z-Prepare a distribution for installation. )rZtrackZprepare_distribution_metadata)�req� req_tracker�finder�build_isolation� abstract_dist�r�D/usr/lib/python3.8/site-packages/pip/_internal/operations/prepare.py�_get_prepared_distribution,s rcsDeZdZdZ�fdd�Zedd��Zdd�Zdd �Zd d �Z �Z S) �RequirementPreparerzPrepares a Requirement csTtt|���||_||_||_|r,t|�}||_|r>t|�}||_ ||_ ||_ dS)N) �superr �__init__�src_dir� build_dirrr � download_dirr�wheel_download_dir� progress_barr)�selfr$r%r#r&r'rr�� __class__rrr"9s zRequirementPreparer.__init__cCs<|js dStj�|j�rdSt�d�tdt|j���dS)NFTz!Could not find download directoryz0Could not find or access download directory '%s')r%�os�path�exists�logger�criticalrr)r(rrr�_download_should_saveas ��z)RequirementPreparer._download_should_savec Cs�|j}|jdkr(|j}t�dt|��nt�d|jp6|�t���b|�|j �t j � t j � |jd��rztd||jf��|r�|jr�t��n|��r�t��|js�|js�t��|j| d�}|r�|s�t�}|j}|jr�|jr�|j}zt||j||||jd�WnFtjk �rB} z$t� d|| �t!d || |f��W5d } ~ XYnX|j�r^|�rXd } nd } nd } | �rrt"|j�t#||j$||j%�} |j&�r�|j�r�|�'|j�W5QRX| S) zCPrepare a requirement that would be obtained from req.link �filez Processing %sz Collecting %szsetup.pyz�pip can't proceed with requirements '%s' due to a pre-existing build directory (%s). This is likely due to a previous installation that failed. pip is being responsible and not assuming it can delete this. Please delete it and try again.)Ztrust_internet)�session�hashesr'z4Could not install requirement %s because of error %szDCould not install requirement %s because of HTTP error %s for URL %sNTF)(�linkZschemeZ file_pathr.�inforrr �ensure_has_source_dirr$r+r,r-�joinZ source_dirr Zis_vcsr Zis_existing_dirrZ original_linkZ is_pinnedrr3r r%Zis_wheelr&rr'rZ HTTPErrorr/rrrrrr0�archive) r(rr2r�require_hashesr4r,r3r%�excZautodelete_unpackedrrrr�prepare_linked_requirementos~    ��   � ��� �z.RequirementPreparer.prepare_linked_requirementc Cszt�d|�t��^|r$td|��|�|j�|�|j �t||j ||j �}|jrb|� |j �|� |�W5QRX|S)z(Prepare an editable requirement z Obtaining %szoThe editable requirement %s cannot be installed when requiring hashes, because there is no single file to hash.)r.r5r rr6r#Zupdate_editabler0rrrr8r%Zcheck_if_exists)r(rr9Z use_user_siterrrrr�prepare_editable_requirement�s( �� � z0RequirementPreparer.prepare_editable_requirementc Cs@t�d|||jj�t��|r*t�d�t|�}W5QRX|S)z1Prepare an already-installed requirement zRequirement %s: %s (%s)z�Since it is already installed, we are trusting this package without checking its hash. To ensure a completely repeatable environment, install into an empty virtualenv.)r.r5Z satisfied_by�versionr �debugr)r(rr9Z skip_reasonrrrr�prepare_installed_requirement s��z1RequirementPreparer.prepare_installed_requirement) �__name__� __module__� __qualname__�__doc__r"�propertyr0r;r<r?� __classcell__rrr)rr 5s ( z"r )/rCZloggingr+Z pip._vendorrZpip._internal.distributionsrZ%pip._internal.distributions.installedrZpip._internal.downloadrZpip._internal.exceptionsrrrr r Zpip._internal.utils.compatr Zpip._internal.utils.hashesr Zpip._internal.utils.loggingr Z pip._internal.utils.marker_filesrZpip._internal.utils.miscrrZpip._internal.utils.typingr�typingrrZpip._internal.indexrZpip._internal.network.sessionrZpip._internal.req.req_installrZpip._internal.req.req_trackerrZ getLoggerr@r.r�objectr rrrr�s.