U .e,@sdZddlZddlZddlmZddlmZddlmZddl m Z ddl m Z m Z mZmZmZddlmZdd lmZdd lmZdd lmZdd lmZmZdd lmZerddlmZddlm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(e)e*Z+ddZ,Gddde-Z.dS)z)Prepares a distribution for installation N)requests))make_distribution_for_install_requirement)InstalledDistribution) unpack_url)DirectoryUrlHashUnsupported HashUnpinnedInstallationErrorPreviousBuildDirErrorVcsHashUnsupported) expanduser) MissingHashes) indent_log)write_delete_marker_file) display_pathnormalize_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_trackerfinderbuild_isolation abstract_distrD/usr/lib/python3.8/site-packages/pip/_internal/operations/prepare.py_get_prepared_distribution,s rcsDeZdZdZfddZeddZddZdd Zd d Z Z S) RequirementPreparerzPrepares a Requirement csTtt|||_||_||_|r,t|}||_|r>t|}||_ ||_ ||_ dS)N) superr __init__src_dir build_dirrr download_dirrwheel_download_dir progress_barr)selfr$r%r#r&r'rr __class__rrr"9s zRequirementPreparer.__init__cCs<|js dStj|jrdStdtdt|jdS)NFTz!Could not find download directoryz0Could not find or access download directory '%s')r%ospathexistsloggercriticalrr)r(rrr_download_should_saveas z)RequirementPreparer._download_should_savec Cs|js t|j}|jdkr2|j}tdt|ntd|jp@|tb| |j t j t j |jdrtd||jf|r|jrtn|rt|js|jst|j| d}|r|st}|j}|jr|jr|j}zt||j||||jdWnFtj k rL} z$t!d|| t"d || |fW5d } ~ XYnX|jrh|rbd } nd } nd } | r|t#|jt$||j%||j&} |j'r|jr|(|jW5QRX| S) zCPrepare a requirement that would be obtained from req.link filez Processing %sz Collecting %szsetup.pyzpip 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)sessionhashesr'z4Could not install requirement %s because of error %szDCould not install requirement %s because of HTTP error %s for URL %sNTF))linkAssertionErrorZschemeZ 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/rrrrrr0archive) r(rr2rrequire_hashesr4r,r3r%excZautodelete_unpackedrrrrprepare_linked_requirementos         z.RequirementPreparer.prepare_linked_requirementc Cs|jstdtd|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_siterrrrrprepare_editable_requirements*    z0RequirementPreparer.prepare_editable_requirementc Csf|jstd|dk s&td|jftd|||jjt|rPtdt|}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)zSince 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.r6versionr debugr)r(rr:Z skip_reasonrrrrprepare_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.typingrtypingrrZpip._internal.indexrZpip._internal.network.sessionrZpip._internal.req.req_installrZpip._internal.req.req_trackerrZ getLoggerrAr.robjectr rrrrs.