a *eg1@sJddlZddlZddlmZddlmZmZmZmZm Z m Z m Z ddl m Z ddlmZddlmZddlmZddlmZdd lmZdd lmZmZdd lmZdd lmZdd lm Z m!Z!erddl"m#Z#ddl$m%Z%GdddeZ&e e&Z'e(e)Z*GdddeZ+dee eee,ee,fdddZ-dee,dddZ.dS)N)Values) TYPE_CHECKING GeneratorListOptionalSequenceTuplecastcanonicalize_name)Version) cmdoptions)IndexGroupCommand)SUCCESS) CommandError)BaseDistributionget_environment)SelectionPreferences) stdlib_pkgs)tabulate write_output PackageFinder) PipSessionc@s"eZdZUdZeed<eed<dS)_DistWithLatestInfozGive the distribution object a couple of extra fields. These will be populated during ``get_outdated()``. This is dirty but makes the rest of the code much cleaner. latest_versionlatest_filetypeN)__name__ __module__ __qualname____doc__r __annotations__strr#r#E/usr/local/lib/python3.9/site-packages/pip/_internal/commands/list.pyrs rcseZdZdZdZdZddddZeddfd d Zed d d ddZ ee e e dddZ deddddZdeddddZdeddddZdeeddddZdeddddZe e e e e dd d!d"ZZS)# ListCommandzt List installed packages, including editables. Packages are listed in a case-insensitive sorted order. Tz %prog [options]N)returncCs*|jjdddddd|jjddddd d|jjd d ddd d|jjd ddddd|jjdddddd|jt|jjddddd|jjddddddd|jjddddd |jjd!d"d#d$d |jjd%dd#d&d'd(|jtttj|j}|jd)||jd)|jdS)*Nz-oz --outdated store_trueFzList outdated packages)actiondefaulthelpz-uz --uptodatezList uptodate packagesz-ez --editablezList editable projects.z-lz--localzSIf in a virtualenv that has global access, do not list globally-installed packages.z--useruserz,Only output packages installed in user-site.)destr(r)r*z--prezYInclude pre-release and development versions. By default, pip only finds stable versions.z--formatstore list_formatcolumns)r/freezejsonzSelect the output format among: columns (default), freeze, or json. The 'freeze' format cannot be used with the --outdated option.)r(r,r)choicesr*z--not-required not_requiredz>List packages that are not dependencies of installed packages.)r(r,r*z--exclude-editable store_falseinclude_editablez%Exclude editable package from output.z--include-editablez%Include editable package from output.T)r(r,r*r)r) cmd_opts add_optionr list_path list_excludemake_option_group index_groupparserinsert_option_group)self index_optsr#r#r$ add_options1s   zListCommand.add_options)optionsr&cs|js |jrt|dSN)outdateduptodatesuperhandle_pip_version_check)r>rA __class__r#r$rFs z$ListCommand.handle_pip_version_checkrr)rAsessionr&cCsBddlm}ddlm}|j||d}td|jd}|j||dS)zK Create a package finder appropriate to this list command. r) LinkCollectorr)rAF) allow_yankedallow_all_prereleases)link_collectorselection_prefs)pip._internal.index.collectorrJ"pip._internal.index.package_finderrcreaterpre)r>rArIrJrrMrNr#r#r$_build_package_finders  z!ListCommand._build_package_finder)rAargsr&cCs|jr|jrtd|jr,|jdkr,tdt|tt}|jrZ| dd|jDddt |j j |j |j|j|j|dD}|jr|||}|jr|||}n|jr|||}|||tS) Nz5Options --outdated and --uptodate cannot be combined.r0z?List format 'freeze' cannot be used with the --outdated option.css|]}t|VqdSrBr ).0nr#r#r$ z"ListCommand.run..cSsg|]}td|qS)r)r )rUdr#r#r$ sz#ListCommand.run..) local_only user_onlyeditables_onlyinclude_editablesskip)rCrDrr.r check_list_path_optionsetrexcludesupdaterpathiter_installed_distributionslocalr+editabler5r3get_not_required get_outdated get_uptodateoutput_package_listingr)r>rArTr_packagesr#r#r$runs6      zListCommand.run_ProcessedDistsrlrAr&cCsdd|||DS)NcSsg|]}|j|jkr|qSr#rversionrUdistr#r#r$rZs z,ListCommand.get_outdated..iter_packages_latest_infosr>rlrAr#r#r$ris zListCommand.get_outdatedcCsdd|||DS)NcSsg|]}|j|jkr|qSr#rprrr#r#r$rZs z,ListCommand.get_uptodate..rtrvr#r#r$rjs zListCommand.get_uptodatecs$dd|Dtfdd|DS)NcSs(h|] }|pdD]}t|jqqS)r#)iter_dependenciesr name)rUrsdepr#r#r$ sz/ListCommand.get_not_required..csh|]}|jvr|qSr#canonical_name)rUpkgZdep_keysr#r$rzrX)listrvr#r~r$rhs zListCommand.get_not_required)rNNc#sr|T}||dtddfdd }t||D]}|dur<|Vq.latest_info..) project_namewheelsdist) find_all_candidatesr|rRmake_candidate_evaluatorsort_best_candidaterqlinkis_wheelrr)rsZall_candidatesZ evaluatorbest_candidateremote_versiontypfinderrAr#r$ latest_infos$  z;ListCommand.iter_packages_latest_infos..latest_info)_build_sessionrSrmap)r>rlrArIrrsr#rr$rus  z&ListCommand.iter_packages_latest_infoscCst|ddd}|jdkr:|r:t||\}}|||n^|jdkr|D]4}|jdkrltd|j|j|jqHtd|j|jqHn|jd krtt ||dS) NcSs|jSrBr{)rsr#r#r$rXz4ListCommand.output_package_listing..)keyr/r0z %s==%s (%s)z%s==%sr1) sortedr.format_for_columnsoutput_package_listing_columnsverboserraw_namerqlocationformat_for_json)r>rlrAdataheaderrsr#r#r$rks    z"ListCommand.output_package_listing)rrr&cCsbt|dkr|d|t|\}}t|dkrL|dddd|D|D] }t|qPdS)Nrr css|]}d|VqdS)-Nr#rUxr#r#r$rW3rXz=ListCommand.output_package_listing_columns..)leninsertrjoinr)r>rrZ pkg_stringssizesvalr#r#r$r(s    z*ListCommand.output_package_listing_columns)rrrr ignore_require_venvusager@rrFrSrr"intrmrirjrhrrurkr __classcell__r#r#rGr$r%&s6X *    ' r%rn)pkgsrAr&cCsddg}|j}|r |ddgtdd|D}|r@|d|jdkrT|d |jdkrh|d g}|D]~}|j|jg}|r|t|j||j |r||j pd |jdkr||j pd |jdkr||j ||qp||fS) z_ Convert the package data into something usable by output_package_listing_columns. Packager ZLatestTypecss|] }|jVqdSrB)rgrr#r#r$rWFrXz%format_for_columns..zEditable project locationrZLocationZ Installer) rCextendanyappendrrZ raw_versionr"rreditable_project_locationr installer)rrArZrunning_outdatedZ has_editablesrZprojrowr#r#r$r9s2           rrocCsg}|D]r}|jt|jd}|jdkr@|jp0d|d<|j|d<|jr^t|j|d<|j|d<|j }|rp||d<| |qt |S) N)rxrqrrrrrrr) rr"rqrrrrCrrrrr1dumps)rlrArrsinforr#r#r$rfs     r)/r1loggingoptparsertypingrrrrrrr pip._vendor.packaging.utilsr Zpip._vendor.packaging.versionr Zpip._internal.clir Zpip._internal.cli.index_commandrpip._internal.cli.status_codesrpip._internal.exceptionsrpip._internal.metadatarr$pip._internal.models.selection_prefsrpip._internal.utils.compatrpip._internal.utils.miscrrrPrpip._internal.network.sessionrrrn getLoggerrloggerr%r"rrr#r#r#r$s4 $             -