3 ig/@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+ej,e-Z.GdddeZ/dee eee0ee0fdddZ1dee0dddZ2dS)N)Values) TYPE_CHECKINGIteratorListOptionalSequenceTuplecast)canonicalize_name) cmdoptions)IndexGroupCommand)SUCCESS) CommandError) LinkCollector) PackageFinder)BaseDistributionget_environment)SelectionPreferences) PipSession) stdlib_pkgs)tabulate write_output)map_multithread)DistributionVersionc@seZdZUdZeedS)_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. N)__name__ __module__ __qualname____doc__rlatest_versionstrlatest_filetyper"r":/tmp/pip-build-88gy_88q/pip/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|jjtj|jjddddd|jjddddd+dd|jjdddd d!|jjd"d#d$d%d!|jjd&dd$d'd(d)|jjtjtjtj|j}|jjd*||jjd*|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_formatcolumnsfreezejsonzBSelect 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)r.r/r0) cmd_opts add_optionr Z list_pathZ list_excludemake_option_group index_groupparserinsert_option_group)self 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_yankedallow_all_prereleases)link_collectorselection_prefs)rcreaterprer)r;r>r?rArBr"r"r#_build_package_finders z!ListCommand._build_package_finder)r>argsr%cCs|jr|jrtdtj|tt}|jrB|jdd|jDddt |j j |j |j |j|j|dD}|jr|j||}|jr|j||}n|jr|j||}|j||tS)Nz5Options --outdated and --uptodate cannot be combined.css|]}t|VqdS)N)r ).0nr"r"r# sz"ListCommand.run..cSsg|]}td|qS)r)r )rGdr"r"r# sz#ListCommand.run..) local_only user_onlyeditables_onlyinclude_editablesskip)outdateduptodaterr Zcheck_list_path_optionsetrZexcludesupdaterpathZiter_installed_distributionslocalr*editabler4r2get_not_required get_outdated get_uptodateoutput_package_listingr )r;r>rFrPpackagesr"r"r#runs*       zListCommand.run_ProcessedDists)r\r>r%cCsdd|j||DS)NcSsg|]}|j|jkr|qSr")rversion)rGdistr"r"r#rKsz,ListCommand.get_outdated..)iter_packages_latest_infos)r;r\r>r"r"r#rYszListCommand.get_outdatedcCsdd|j||DS)NcSsg|]}|j|jkr|qSr")rr_)rGr`r"r"r#rKsz,ListCommand.get_uptodate..)ra)r;r\r>r"r"r#rZszListCommand.get_uptodatecs$dd|Dtfdd|DS)NcSs(h|] }|jpfD]}t|jqqSr")Ziter_dependenciesr name)rGr`depr"r"r# sz/ListCommand.get_not_required..csh|]}|jkr|qSr")canonical_name)rGpkg)dep_keysr"r#rds)list)r;r\r>r")rgr#rXszListCommand.get_not_requiredrc #sb|jN}|j|dtddfdd }x t||D]}|dk r>|Vq>WWdQRXdS)Nr)r`r%cslj|j}js dd|D}j|jd}|j|}|dkrDdS|j}|jjrXd}nd}||_||_ |S)NcSsg|]}|jjs|qSr")r_ is_prerelease)rG candidater"r"r#rKszOListCommand.iter_packages_latest_infos..latest_info..) project_namewheelsdist) find_all_candidatesrerDZmake_candidate_evaluatorZsort_best_candidater_linkis_wheelrr!)r`all_candidatesZ evaluatorbest_candidateremote_versiontyp)finderr>r"r# latest_infos    z;ListCommand.iter_packages_latest_infos..latest_info)_build_sessionrErr)r;r\r>r?rvr`r")rur>r#ras  z&ListCommand.iter_packages_latest_infoscCst|ddd}|jdkr:|r:t||\}}|j||nb|jdkrxV|D]4}|jdkrntd|j|j|jqJtd|j|jqJWn|jd krtt ||dS) NcSs|jS)N)re)r`r"r"r# sz4ListCommand.output_package_listing..)keyr.r/z %s==%s (%s)z%s==%sr0) sortedr-format_for_columnsoutput_package_listing_columnsverboserraw_namer_locationformat_for_json)r;r\r>dataheaderr`r"r"r#r[s     z"ListCommand.output_package_listing)rrr%cCsft|dkr|jd|t|\}}t|dkrL|jddjtdd|x|D] }t|qRWdS)Nrrz cSsd|S)N-r")xr"r"r#rx%sz.)leninsertrjoinmapr)r;rr pkg_stringssizesvalr"r"r#r}s     z*ListCommand.output_package_listing_columns)rrrrZignore_require_venvusager=rrrrErr intr]rYrZrXrrar[r}r"r"r"r#r$(s&V% %r$r^)pkgsr>r%cCsddg}|j}|r |jddgtdd|D}|r@|jd|jdkrT|jd |jdkrh|jd g}x|D]}|jt|jg}|r|jt|j|j|j |r|j|j pd |jdkr|j|j pd |jdkr|j|j |j|qrW||fS) z_ Convert the package data into something usable by output_package_listing_columns. PackageVersionLatestTypecss|] }|jVqdS)N)rW)rGrr"r"r#rI8sz%format_for_columns..zEditable project locationrzLocationZ Installer) rQextendanyappendr~rr r_rr!editable_project_locationr installer)rr>rrunning_outdatedZ has_editablesrprojrowr"r"r#r|+s2          r|)r\r>r%cCsg}xz|D]r}|jt|jd}|jdkrB|jp2d|d<|j|d<|jr`t|j|d<|j|d<|j }|rr||d<|j |q Wt j |S) N)rbr_rzrrrrr!r) rr r_r~rrrQrr!rrr0dumps)r\r>rr`inforr"r"r#rXs    r)3r0loggingoptparserZtypingrrrrrrr pip._vendor.packaging.utilsr Zpip._internal.clir Zpip._internal.cli.req_commandr Zpip._internal.cli.status_codesr Zpip._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.baserrr^ getLoggerrloggerr$r r|rr"r"r"r#s6 $              "+