a [f/@sdddlZddlZddlmZddlmZmZmZmZm 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/dee eee0ee0fdddZ1dee0dddZ2dS)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$?/usr/lib/python3.9/site-packages/pip/_internal/commands/list.pyrs rc@seZdZdZdZdZddddZeee dd d Z ee e e d d d ZdeddddZdeddddZdeddddZdeeddddZdeddddZe e e e e ddddZdS) 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)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) Zcmd_optsZ add_optionr Z list_pathZ list_excludeZmake_option_groupZ index_groupparserZinsert_option_group)selfZ index_optsr$r$r% add_options3s   zListCommand.add_options)optionssessionr'cCs*tj||d}td|jd}tj||dS)zK Create a package finder appropriate to this list command. )r:F)Z allow_yankedZallow_all_prereleases)link_collectorselection_prefs)rZcreaterprer)r8r:r;r<r=r$r$r%_build_package_findersz!ListCommand._build_package_finder)r:argsr'cCs|jr|jrtdt|tt}|jrB|dd|jDddt |j j |j |j |j|j|dD}|jr|||}|jr|||}n|jr|||}|||tS)Nz5Options --outdated and --uptodate cannot be combined.css|]}t|VqdSNr ).0nr$r$r% z"ListCommand.run..cSsg|]}td|qS)r)r )rBdr$r$r% sz#ListCommand.run..)Z local_onlyZ user_onlyZeditables_onlyZinclude_editablesskip)outdatedZuptodaterr Zcheck_list_path_optionsetrZexcludesupdaterpathZiter_installed_distributionslocalr,editabler6r4get_not_required get_outdated get_uptodateoutput_package_listingr)r8r:r@rHpackagesr$r$r%runs.      zListCommand.run_ProcessedDistsrSr:r'cCsdd|||DS)NcSsg|]}|j|jkr|qSr$rversionrBdistr$r$r%rGs z,ListCommand.get_outdated..iter_packages_latest_infosr8rSr:r$r$r%rPs zListCommand.get_outdatedcCsdd|||DS)NcSsg|]}|j|jkr|qSr$rWrYr$r$r%rGs z,ListCommand.get_uptodate..r[r]r$r$r%rQs zListCommand.get_uptodatecs$dd|Dtfdd|DS)NcSs(h|] }|pdD]}t|jqqS)r$)Ziter_dependenciesr name)rBrZZdepr$r$r% sz/ListCommand.get_not_required..csh|]}|jvr|qSr$canonical_name)rBpkgZdep_keysr$r%r_rE)listr]r$rcr%rOs zListCommand.get_not_requiredrc#sr|T}||dtddfdd }t||D]}|dur<|Vq.latest_info..)Z project_nameZwheelZsdist) Zfind_all_candidatesrar>Zmake_candidate_evaluatorZsort_best_candidaterXlinkZis_wheelrr)rZZall_candidatesZ evaluatorZbest_candidateZremote_versiontypfinderr:r$r% latest_infos$  z;ListCommand.iter_packages_latest_infos..latest_info)Z_build_sessionr?rr)r8rSr:r;rjrZr$rhr%r\s  z&ListCommand.iter_packages_latest_infoscCst|ddd}|jdkr:|r:t||\}}|||n^|jdkr|D]4}|jdkrltd|j|j|jqHtd|j|jqHn|jd krtt ||dS) NcSs|jSrAr`)rZr$r$r% rEz4ListCommand.output_package_listing..)keyr0r1z %s==%s (%s)z%s==%sr2) sortedr/format_for_columnsoutput_package_listing_columnsverboserraw_namerXlocationformat_for_json)r8rSr:dataheaderrZr$r$r%rRs    z"ListCommand.output_package_listing)rurvr'cCsbt|dkr|d|t|\}}t|dkrL|ddtdd||D] }t|qPdS)Nrrm cSsd|S)N-r$)xr$r$r%rk%rEz.)leninsertrjoinmapr)r8rurvZ pkg_stringsZsizesvalr$r$r%rps    z*ListCommand.output_package_listing_columns)rrr r!Zignore_require_venvusager9rrrr?rr#intrTrPrQrOrr\rRrpr$r$r$r%r&(s4V %    ' r&rU)pkgsr:r'cCsddg}|j}|r |ddgtdd|D}|r@|d|jdkrT|d |jdkrh|d g}|D]}|jt|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. ZPackageZVersionZLatestTypecss|] }|jVqdSrA)rN)rBryr$r$r%rD8rEz%format_for_columns..zEditable project locationrmZLocationZ Installer) rIextendanyappendrqrrr#rXrreditable_project_locationrs installer)rr:rvZrunning_outdatedZ has_editablesruZprojrowr$r$r%ro+s2          rorVcCsg}|D]r}|jt|jd}|jdkr@|jp0d|d<|j|d<|jr^t|j|d<|j|d<|j }|rp||d<| |qt |S) N)r^rXrmrrsrrrr) rrr#rXrqrsrrIrrrrr2dumps)rSr:rurZinforr$r$r%rtXs     rt)3r2ZloggingZoptparsertypingrrrrrrr Zpip._vendor.packaging.utilsr Zpip._internal.clir Zpip._internal.cli.req_commandr Zpip._internal.cli.status_codesrZpip._internal.exceptionsrZpip._internal.index.collectorrZ"pip._internal.index.package_finderrZpip._internal.metadatarrZ$pip._internal.models.selection_prefsrZpip._internal.network.sessionrZpip._internal.utils.compatrZpip._internal.utils.miscrrZpip._internal.utils.parallelrZpip._internal.metadata.baserrrUZ getLoggerrloggerr&r#rortr$r$r$r%s8 $               -