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|j}|jdkr(|j}tdt|ntd|jp6|tb||j t j t j |jdrztd||jf|r|jrtn|rt|js|jst|j| d}|r|st}|j}|jr|jr|j}zt||j||||jdWnFtjk rB} z$t d|| t!d || |fW5d } ~ XYnX|jr^|rXd } nd } nd } | rrt"|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)(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/rrrrrr0archive) r(rr2rrequire_hashesr4r,r3r%excZautodelete_unpackedrrrrprepare_linked_requirementos~         z.RequirementPreparer.prepare_linked_requirementc Csztd|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_siterrrrrprepare_editable_requirements(   z0RequirementPreparer.prepare_editable_requirementc Cs@td|||jjt|r*tdt|}W5QRX|S)z1Prepare an already-installed requirement zRequirement %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.)r.r5Z satisfied_byversionr debugr)r(rr9Z skip_reasonrrrrprepare_installed_requirement sz1RequirementPreparer.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.typingrtypingrrZpip._internal.indexrZpip._internal.network.sessionrZpip._internal.req.req_installrZpip._internal.req.req_trackerrZ getLoggerr@r.robjectr rrrrs.