o ai/ @sjddlZddlZddlmZddlmZmZmZmZm Z m Z m Z ddl m Z ddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZmZdd lmZdd lm Z ddl!m"Z"ddl#m$Z$m%Z%ddl&m'Z'erddl(m)Z)GdddeZ*e e*Z+e,e-Z.GdddeZ/dddede eee0ee0ffddZ1dddede0fddZ2dS)N)Values) TYPE_CHECKINGIteratorListOptionalSequenceTuplecastcanonicalize_name) cmdoptions)IndexGroupCommand)SUCCESS) CommandError) LinkCollector) PackageFinder)BaseDistributionget_environment)SelectionPreferences) PipSession) stdlib_pkgs)tabulate write_output)map_multithread)DistributionVersionc@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$/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-5.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_internal/commands/list.pyrs  rc@seZdZdZdZdZd ddZded ede fd d Z ded e e de fd dZdddeddfddZdddeddfddZdddeddfddZdddededfddZdddeddfddZde e e de e ddfddZdS)! ListCommandzt List installed packages, including editables. Packages are listed in a case-insensitive sorted order. Tz %prog [options]returnNcCs*|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)r0freezejsonzBSelect the output format among: columns (default), freeze, or json)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_options3s   zListCommand.add_optionsoptionssessioncCs*tj||d}td|jd}tj||dS)zK Create a package finder appropriate to this list command. )rBF) allow_yankedallow_all_prereleases)link_collectorselection_prefs)rcreaterprer)r?rBrCrFrGr$r$r%_build_package_findersz!ListCommand._build_package_finderargscCs|jr |jr tdt|tt}|jr!|dd|jDddt |j j |j |j |j|j|dD}|jr@|||}|jrJ|||}n |jrS|||}|||tS)Nz5Options --outdated and --uptodate cannot be combined.css|]}t|VqdSNr ).0nr$r$r% sz"ListCommand.run..cSsg|]}td|qS)r)r )rMdr$r$r% sz#ListCommand.run..) local_only user_onlyeditables_onlyinclude_editablesskip)outdatedZuptodaterr check_list_path_optionsetrexcludesupdaterpathiter_installed_distributionslocalr,editabler6r4get_not_required get_outdated get_uptodateoutput_package_listingr)r?rBrKrVpackagesr$r$r%runs.      zListCommand.runrd_ProcessedDistscCdd|||DS)NcSsg|] }|j|jkr|qSr$rversionrMdistr$r$r%rQ  z,ListCommand.get_outdated..iter_packages_latest_infosr?rdrBr$r$r%ra zListCommand.get_outdatedcCrg)NcSsg|] }|j|jkr|qSr$rhrjr$r$r%rQrlz,ListCommand.get_uptodate..rmror$r$r%rbrpzListCommand.get_uptodatecs$dd|Dtfdd|DS)NcSs(h|]}|p dD]}t|jq qS)r$)iter_dependenciesr name)rMrkdepr$r$r% s z/ListCommand.get_not_required..csh|] }|jvr|qSr$canonical_name)rMpkgZdep_keysr$r%rts)listror$rxr%r`s zListCommand.get_not_requiredrc#sx|,}||dddtdffdd }t||D] }|dur)|Vq WddS1s5wYdS)Nrkrr'csl|j}jsdd|D}j|jd}||}|dur"dS|j}|jjr,d}nd}||_||_ |S)NcSsg|]}|jjs|qSr$)ri is_prerelease)rM candidater$r$r%rQs zOListCommand.iter_packages_latest_infos..latest_info..) project_namewheelsdist) find_all_candidatesrvrImake_candidate_evaluatorsort_best_candidaterilinkis_wheelrr)rkZall_candidatesZ evaluatorbest_candidateremote_versiontypfinderrBr$r% latest_infos$  z;ListCommand.iter_packages_latest_infos..latest_info)_build_sessionrJrr)r?rdrBrCrrkr$rr%rns  "z&ListCommand.iter_packages_latest_infoscCst|ddd}|jdkr|rt||\}}|||dS|jdkrB|D]}|jdkr7td|j|j|jq%td|j|jq%dS|jd krPtt ||dSdS) NcSs|jSrLru)rkr$r$r% sz4ListCommand.output_package_listing..)keyr0r1z %s==%s (%s)z%s==%sr2) sortedr/format_for_columnsoutput_package_listing_columnsverboserraw_namerilocationformat_for_json)r?rdrBdataheaderrkr$r$r%rcs$   z"ListCommand.output_package_listingrrcCsbt|dkr |d|t|\}}t|dkr&|ddtdd||D]}t|q(dS)Nrr cSsd|S)N-r$)xr$r$r%r%sz.)leninsertrjoinmapr)r?rrZ pkg_stringssizesvalr$r$r%rs     z*ListCommand.output_package_listing_columns)r'N)rrr r!ignore_require_venvusagerArrrrJrr#intrerarbr`rrnrcrr$r$r$r%r&(sn U $      &  r&pkgsrfrBr'cCsddg}|j}|r|ddgtdd|D}|r |d|jdkr*|d |jdkr4|d g}|D]A}|jt|jg}|rR|t|j||j |r\||j pZd |jdkri||j pgd |jdkrt||j ||q8||fS) z_ Convert the package data into something usable by output_package_listing_columns. PackageVersionZLatestTypecss|]}|jVqdSrL)r_)rMrr$r$r%rO8sz%format_for_columns..zEditable project locationrZLocationZ Installer) rWextendanyappendrrr#rirreditable_project_locationr installer)rrBrZrunning_outdatedZ has_editablesrZprojrowr$r$r%r+s2          rrdcCsg}|D]9}|jt|jd}|jdkr |jpd|d<|j|d<|jr/t|j|d<|j|d<|j }|r8||d<| |qt |S) N)rrrirrrrrrr) rr#rirrrrWrrrrr2dumps)rdrBrrkinforr$r$r%rXs      r)3r2loggingoptparsertypingrrrrrrr pip._vendor.packaging.utilsr pip._internal.clir pip._internal.cli.req_commandr pip._internal.cli.status_codesrpip._internal.exceptionsrpip._internal.index.collectorr"pip._internal.index.package_finderrpip._internal.metadatarr$pip._internal.models.selection_prefsrpip._internal.network.sessionrpip._internal.utils.compatrpip._internal.utils.miscrrZpip._internal.utils.parallelrZpip._internal.metadata.baserrrf getLoggerrloggerr&r#rrr$r$r$r%sB $              -