a  ze{@s$ddlZddlZddlZddlZddlZddlZddlmZmZm Z m Z m Z m Z m Z ddlmZmZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lm Z dd l!m"Z"m#Z#dd l$m%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+ddl,m+Z-ddl.m/Z0ddl1m2Z2ddl1m3Z4ddl5m6Z6ddl7m8Z8m9Z9ddl:m;Z;ddlm?Z?ddl@mAZAddlBmCZCddlDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLddlMmNZNddlOmPZPmQZQddlRmSZSddlTmUZUeVeWZXeYe d d!d"ZZGd#d$d$Z[e[eYd%d&d'Z\dS)(N)AnyDictIterableListOptionalSequenceUnion) pkg_resourcessix)Marker) Requirement) SpecifierSet)canonicalize_name)Version)parse)Pep517HookCaller) Distribution)BuildEnvironmentNoOpBuildEnvironment)InstallationError) get_scheme)Link)generate_metadata)install_editable)LegacyInstallFailure)install) install_wheel)load_pyproject_tomlmake_pyproject_path)UninstallPathSet) deprecated)direct_url_from_link)Hashes) indent_log)ask_path_exists backup_dir display_pathdist_in_site_packagesdist_in_usersiteget_distributionhide_urlredact_auth_from_url) get_metadata) TempDirectory tempdir_kinds)running_under_virtualenv)vcs)metadata_directoryreturncCs|tj}tj|\}}t||}|drJtj}tj |d}n.|dsXJtj }tj |ddd}||||dS)zQReturn a pkg_resources.Distribution for the provided metadata directory. z .egg-inforz .dist-info-) project_namemetadata) rstriposseppathsplitr PathMetadataendswithrsplitextDistInfoDistribution)r1dist_dirbase_dir dist_dir_namer5dist_cls dist_namerD_/opt/bitninja-python-dojo/embedded/lib/python3.9/site-packages/pip/_internal/req/req_install.py _get_dist<s   rFc@seZdZdZdOeeeeedfeee ee eeeee eee eee ee efee eeddddZedd d Zedd d Zedd dZeeedddZeedddZeedddZdPee eedddZeedddZdQeedddZeedddZeeeed d!d"Zddd#d$Zddd%d&Zedd'd(d)Zeedd*d+Z eedd,d-Z!eedd.d/Z"eedd0d1Z#ddd2d3Z$edd4d5Z%ddd6d7Z&ee'dd8d9Z(e)dd:d;Z*dddd?d@Z,dddAdBZ-dSeeee.dCdDdEZ/eeeedFdGdHZ0eeddIdJdKZ1dTe eee2eeeeeeeeeeddL dMdNZ3dS)UInstallRequirementz Represents something that may be installed later on, may have information about where to fetch the relevant requirement and also contains logic for installing the said requirement. FNrD)req comes_fromeditablelinkmarkers use_pep517isolatedinstall_optionsglobal_options hash_options constraintextras user_suppliedr2cCs|dust|tsJ|||_||_| |_||_d|_d|_|jrj|sLJ|jrjt j t j |j |_|dur|r|jrt|j}||_|_d|_d|_|jr|jjr|jj |_| r| |_n |rdd|jD|_nt|_|dur|r|j}||_d|_d|_d|_d|_|r|ng|_| r,| ng|_| r<| ni|_d|_| |_ ||_!t"|_#d|_$d|_%g|_&d|_'||_(d|_)dS)NFcSsh|]}t|qSrD)r safe_extra.0extrarDrDrE sz.InstallRequirement.__init__..)* isinstancer rHrIrRrJlegacy_install_reason source_diris_filer7r9normpathabspath file_pathurlrrK original_linkoriginal_link_is_in_wheel_cachelocal_file_pathrSsetmarkerrL satisfied_byshould_reinstall_temp_build_dirinstall_succeededrOrPrQpreparedrTrNr build_envr1pyproject_requiresrequirements_to_checkpep517_backendrMneeds_more_preparation)selfrHrIrJrKrLrMrNrOrPrQrRrSrTrDrDrE__init__]s^      zInstallRequirement.__init__)r2cCs|jr.t|j}|jrF|dt|jj7}n|jrBt|jj}nd}|jdurf|dt|jj7}|j rt |j tr|j }n |j }|r|d|d7}|S)Nz from {}zz in {}z (from )) rHstrrKformatr+rargr&locationrIrZ from_pathrqsrIrDrDrE__str__s     zInstallRequirement.__str__cCsd|jjt||jS)Nz<{} object: {} editable={!r}>)ru __class____name__rtrJrqrDrDrE__repr__szInstallRequirement.__repr__cs>t|t}fddt|D}dj|jjd|dS)z>An un-tested helper for getting state, for debugging. c3s|]}d||VqdS)z{}={!r}N)ru)rWattr attributesrDrE sz2InstallRequirement.format_debug..z<{name} object: {{{state}}}>z, )namestate)varssortedrur{r|join)rqnamesrrDrrE format_debugs zInstallRequirement.format_debugcCs|jdurdSt|jjSN)rHr safe_namerr}rDrDrErs zInstallRequirement.namecCs|jjSr)rH specifierr}rDrDrErszInstallRequirement.specifiercCs$|j}t|dko"tt|jdvS)zReturn whether I am pinned to an exact version. For example, some-package==1.2 is pinned; some-package>1.2 is not. >=====)rlennextiteroperator)rq specifiersrDrDrE is_pinneds zInstallRequirement.is_pinned)extras_requestedr2cs0|sd}jdur(tfdd|DSdSdS)N)c3s|]}jd|iVqdS)rXN)rLevaluaterVr}rDrEr sz3InstallRequirement.match_markers..T)rLany)rqrrDr}rE match_markerss  z InstallRequirement.match_markerscCs t|jS)zReturn whether any known-good hashes are specified as options. These activate --require-hashes mode; hashes specified as part of a URL do not. )boolrQr}rDrDrEhas_hash_optionssz#InstallRequirement.has_hash_optionsT)trust_internetr2cCsB|j}|r|jn|j}|r:|jr:||jg|jt|S)aReturn a hash-comparer that considers my option- and URL-based hashes to be known-good. Hashes in URLs--ones embedded in the requirements file, not ones downloaded from an index server--are almost peers with ones from flags. They satisfy --require-hashes (whether it was implicitly or explicitly activated) but do not activate it. md5 and sha224 are not allowed in flags, which should nudge people toward good algos. We always OR all hashes together, even ones from URLs. :param trust_internet: Whether to trust URL-based (#md5=...) hashes downloaded from the internet, as by populate_link() ) rQcopyrKrbhash setdefault hash_nameappendr")rqr good_hashesrKrDrDrEhashess   zInstallRequirement.hashescCsP|jdurdSt|j}|jrLt|jtr2|j}n |j}|rL|d|7}|S)z@Format a nice indicator to show where this "comes from" Nz->)rHrtrIrZrwrxrDrDrErw/s     zInstallRequirement.from_path) build_dir autodeleteparallel_buildsr2cCs|dus J|jdur*|jjs"J|jjS|jdurLttjdd|_|jjSt|j}|rn|dt j }t j |st d|t |t j||}|rdnd}t||tjddjS)NT)kindglobally_managed_zCreating directory %sF)r9deleterr)rir9rHr-r. REQ_BUILDrruuiduuid4hexr7existsloggerdebugmakedirsr)rqrrrdir_nameactual_build_dir delete_argrDrDrEensure_build_location>s.         z(InstallRequirement.ensure_build_locationcCsn|jdusJ|jdusJ|jdus*Jtt|jdtrDd}nd}td|jd||jdg|_dS)z3Set requirement after generating metadata. NrrrrName)rHr5r\rZ parse_versionrr r)rqoprDrDrE_set_requirementisz#InstallRequirement._set_requirementcCsDt|jd}t|jj|kr"dStd|j||jt||_dS)NrzeGenerating metadata for package %s produced metadata for project name %s. Fix your #egg=%s fragments.)rr5rHrrwarningr )rq metadata_namerDrDrEwarn_on_mismatching_name~s z+InstallRequirement.warn_on_mismatching_name) use_user_siter2cCs|jdurdSt|jj}|s"dS|j}|duo@|jjj|dd}|sd|_|rt|r`d|_qt rt |rt d |j |jqd|_n|jrd|_d|_n||_dS)zFind an installed distribution that satisfies or conflicts with this requirement, and set self.satisfied_by or self.should_reinstall appropriately. NT) prereleaseszVWill not install to the user site because it will lack sys.path precedence to {} in {})rHr)rversionrcontainsrgr(rhr/r'rrur4rvrJ)rqr existing_distexisting_versionversion_compatiblerDrDrEcheck_if_existss6  z"InstallRequirement.check_if_existscCs|js dS|jjS)NF)rKis_wheelr}rDrDrErszInstallRequirement.is_wheelcCstj|j|jr|jjpdS)Nr)r7r9rr\rKsubdirectory_fragmentr}rDrDrEunpacked_source_directorysz,InstallRequirement.unpacked_source_directorycCs(|jsJd|tj|jd}|S)NNo source dir for zsetup.py)r\r7r9rr)rqsetup_pyrDrDrE setup_py_pathsz InstallRequirement.setup_py_pathcCs|jsJd|t|jS)Nr)r\rrr}rDrDrEpyproject_toml_pathsz&InstallRequirement.pyproject_toml_pathcCs^t|j|j|jt|}|dur*d|_dSd|_|\}}}}||_||_t|j||d|_ dS)aALoad the pyproject.toml file. After calling this routine, all of the attributes related to PEP 517 processing for this requirement have been set. In particular, the use_pep517 attribute can be used to determine whether we should follow the PEP 517 or legacy (setup.py) code path. NFT) backend_path) rrMrrrtrnrmrrro)rqpyproject_toml_datarequiresbackendcheckrrDrDrErs  z&InstallRequirement.load_pyproject_tomlcCst|jsV|jsJtj|js.td|dt|j|j|j|j |j pPd|j dS|j dusdJt |j|j dS)zKInvokes metadata generator functions, with the required arguments. z-File "setup.py" not found for legacy project .zfrom )rlrr\rNdetailsN)rlr)rMrr7r9rrrgenerate_metadata_legacyrlrNrrKrorr}rDrDrE_generate_metadatas$  z%InstallRequirement._generate_metadatacCs^|js Jt||_Wdn1s00Y|jsJ|n||dS)zEnsure that project metadata is available. Under PEP 517, call the backend hook to prepare the metadata. Under legacy processing, call setup.py egg-info. N)r\r#rr1rrrassert_source_matches_versionr}rDrDrEprepare_metadatas ( z#InstallRequirement.prepare_metadatacCst|dst||_|jS)N _metadata)hasattrr,get_distrr}rDrDrEr5s zInstallRequirement.metadatacCs t|jSr)rFr1r}rDrDrEr!szInstallRequirement.get_distcCsR|js J|jd}|jjr8||jjvr8td||ntdt|j||dS)Nrz'Requested %s, but installing version %sz;Source in %s has version %s, which satisfies requirement %s)r\r5rHrrrrr&)rqrrDrDrEr$s  z0InstallRequirement.assert_source_matches_version) parent_dirrrr2cCs |jdur|j|||d|_dS)aAEnsure that a source_dir is set. This will create a temporary build dir if the name of the requirement isn't known yet. :param parent_dir: The ideal pip parent_dir for the source_dir. Generally src_dir for editables and build_dir for sdists. :return: self.source_dir N)rr)r\r)rqrrrrDrDrEensure_has_source_dir6s  z(InstallRequirement.ensure_has_source_dircCs|jstd|jdS|js"J|js,J|jjdkrCannot update repository at %s; repository location is unknownfilezUnsupported VCS URL )ra) rKrrr\rJschemer0get_backend_for_schemerar*obtain)rq vcs_backend hidden_urlrDrDrEupdate_editableMs    z"InstallRequirement.update_editable) auto_confirmverboser2cCsR|js Jt|jj}|s,td|jdStd|t|}||||S)a Uninstall the distribution currently satisfying this requirement. Prompts before removing or modifying files unless ``auto_confirm`` is True. Refuses to delete or modify files outside of ``sys.prefix`` - thus uninstallation within a virtual environment can only modify that virtual environment, even if the virtualenv is linked to global site-packages. z#Skipping %s as it is not installed.NzFound existing installation: %s) rHr)rrrinfor from_distremove)rqrrdistuninstalled_pathsetrDrDrE uninstallbs     zInstallRequirement.uninstall)r9 parentdirrootdirr2cCs8tttddd}tj||}|||}|jd|S)N)rprefixr2cSsN||tjjs&Jd|d||t|dd}|tjjd}|S)Nzname z doesn't start with prefix r/) startswithr7r9r8rreplace)rrrDrDrE_clean_zip_name~s z=InstallRequirement._get_archive_name.._clean_zip_namer)rtr7r9rr)rqr9rrrrrDrDrE_get_archive_name|s z$InstallRequirement._get_archive_name)rr2cCs|js J|durdSd}d|j|jd}tj||}tj|rtdt |d}|dkrjd}nj|d krt d t |t |nF|d krt |}t d t |t |t||n|d krtd|sdStj|d tjdd}|tjtj|j}t|D]~\} } } | D]6} |j| | |d} t| d}d|_||dq$| D]0}|j|| |d}tj| |}|||q`qWdn1s0Yt dt |dS)z}Saves archive to provided build_dir. Used for saving downloaded VCS requirements as part of `pip download`. NTz {}-{}.ziprz8The file {} exists. (i)gnore, (w)ipe, (b)ackup, (a)bort )iwbarFrz Deleting %srzBacking up %s to %sr) allowZip64)rrrirzSaved %s)r\rurr5r7r9rrr$r&rrrr%shutilmovesysexitzipfileZipFile ZIP_DEFLATEDnormcaser_rwalkrZipInfo external_attrwritestrwriter)rqrcreate_archive archive_name archive_pathresponse dest_file zip_outputdirdirpathdirnames filenamesdirname dir_arcnamezipdirfilename file_arcnamerDrDrEarchivesh      4zInstallRequirement.archive) rOrProothomerwarn_script_locationr pycompiler2c Cst|j||||j|d} |dur$|ng}|jr^t||||||j|j|j|j|jd d|_dS|j r|j snJd} |j rt |j |j |j} t|j|j | t|j||| |jdd|_dSt||j}t||j}z8t|||||||| |j|j|j|j|jt|jd} WnRtyD} zd|_tj| jWYd} ~ n$d} ~ 0ty^d|_Yn0| |_| r|jdkrtd|jd ddd dS) N)userrrrNr)rrrrrrNrlrT)rreq_descriptionrr direct_url requested)rOrPrrrrrrrrNreq_namerlrrFi zg{} was installed using the legacy 'setup.py install' method, because a wheel could not be built for it.z+to fix the wheel build issue reported abovereason replacementgone_inissue)rrrNrJinstall_editable_legacyrrlrrjrrdrbr!r\rcrrtrHrTlistrPrOinstall_legacyrr reraiseparent Exceptionr[r ru) rqrOrPrrrrrrrrsuccessexcrDrDrErs        zInstallRequirement.install) FNNNFNNNFrDF)N)T)FF)FF)NNNNTFT)4r| __module__ __qualname____doc__rr rrtrrr rrrrrrzr~rpropertyrr rrrrr"rrwrrrrrrrrrrrrr5rrrrrrrrrrrrDrDrDrErGVs    l    +,  A rG)rHr2cCs>d}|jsd}n|jrd}n |jr&d}|r:tddddd|S) Nrz3Unnamed requirements are not allowed as constraintsz4Editable requirements are not allowed as constraintszConstraints cannot have extrasaConstraints are only allowed to take the form of a package name and a version specifier. Other forms were originally permitted as an accident of the implementation, but were undocumented. The new implementation of the resolver no longer supports these forms.z+replacing the constraint with a requirementi r!)rrJrSr )rHproblemrDrDrEcheck_invalid_constraint_type4sr3)]loggingr7rrrrtypingrrrrrrr pip._vendorr r Zpip._vendor.packaging.markersr Z"pip._vendor.packaging.requirementsr Z pip._vendor.packaging.specifiersr pip._vendor.packaging.utilsrZpip._vendor.packaging.versionrrrZpip._vendor.pep517.wrappersrpip._vendor.pkg_resourcesrpip._internal.build_envrrpip._internal.exceptionsrpip._internal.locationsrpip._internal.models.linkr'pip._internal.operations.build.metadatar.pip._internal.operations.build.metadata_legacyr0pip._internal.operations.install.editable_legacyrr&'pip._internal.operations.install.legacyrrr(&pip._internal.operations.install.wheelrpip._internal.pyprojectrrpip._internal.req.req_uninstallrpip._internal.utils.deprecationr &pip._internal.utils.direct_url_helpersr!pip._internal.utils.hashesr"pip._internal.utils.loggingr#pip._internal.utils.miscr$r%r&r'r(r)r*r+pip._internal.utils.packagingr,pip._internal.utils.temp_dirr-r.pip._internal.utils.virtualenvr/pip._internal.vcsr0 getLoggerr|rrtrFrGr3rDrDrDrEsZ$                      (    c