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�|js t�|j}|jdkr2|j}t�dt|��nt�d|jp@|�t���b|� |j �t j � t j �|jd��r�td||jf��|r�|jr�t��n|��r�t��|js�|js�t��|j| d�}|r�|s�t�}|j}|jr�|jr�|j}zt||j||||jd�WnFtj k �rL} z$t�!d|| �t"d || |f��W5d } ~ XYnX|j�rh|�rbd } nd } nd } | �r|t#|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))�link�AssertionErrorZschemeZ 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 Cs�|jstd��t�d|�t��^|r2td|��|�|j�|�|j �t ||j ||j �}|j rp|� |j�|�|�W5QRX|S)z(Prepare an editable requirement z-cannot prepare a non-editable req as editablez Obtaining %szoThe editable requirement %s cannot be installed when requiring hashes, because there is no single file to hash.)Zeditabler5r.r6r rr7r#Zupdate_editabler0rrrr9r%Zcheck_if_exists)r(rr:Z use_user_siterrrrr�prepare_editable_requirement�s*  �� � z0RequirementPreparer.prepare_editable_requirementc Csf|jstd��|dk s&td|jf��t�d|||jj�t��|rPt�d�t|�}W5QRX|S)z1Prepare an already-installed requirement z(req should have been satisfied but isn'tNzAdid not get skip reason skipped but req.satisfied_by is set to %rzRequirement %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.)Z satisfied_byr5r.r6�versionr �debugr)r(rr:Z skip_reasonrrrr�prepare_installed_requirement s&  ����z1RequirementPreparer.prepare_installed_requirement) �__name__� __module__� __qualname__�__doc__r"�propertyr0r<r=r@� __classcell__rrr)rr 5s ( z"r )/rDZloggingr+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 getLoggerrAr.r�objectr rrrr�s.