pip icon indicating copy to clipboard operation
pip copied to clipboard

Suggestion - pip list with summary

Open jeanphi-baconnais opened this issue 4 years ago • 6 comments

What's the problem this feature will solve?

When i make a pip list i see a lot of modules, but i don't easily remember what it each module :smile:

Describe the solution you'd like

Is it possible to have one pip list which return the summary of each module ? or an argument on this command ?

Alternative Solutions

Additional context

jeanphi-baconnais avatar Oct 01 '20 14:10 jeanphi-baconnais

What do you mean by summary? Personally I feel pip doesn’t need to get involved in complex functionalities and should focus on making it easy for users to compose commands instead. In this case you can write a script to call pip show on each package to get what you want (I guess).

uranusjr avatar Oct 01 '20 14:10 uranusjr

Hi, For example, you can use :

pip list --format=columns | tail -n +3| cut -d" " -f1  | xargs -n1 pip show | grep -E 'Name|Summary' 

in an alias command

thib1984 avatar Oct 01 '20 15:10 thib1984

For example this is a part of my pip list :

pip list
Package Version Location


ansible 2.9.2 appdirs 1.4.3 apturl 0.5.2 asn1crypto 1.2.0 attrs 19.2.0 beautifulsoup4 4.6.0 blinker 1.4 bpytop 1.0.40 Brlapi 0.6.6 cached-property 1.5.1 certifi 2019.11.28 cffi 1.12.3 chardet 3.0.4 Click 7.0 colorama 0.4.1 command-not-found 0.3 cryptography 2.8 cupshelpers 1.0 defer 1.0.6 defusedxml 0.6.0 distro 1.5.0 distro-info 0.18ubuntu0.18.04.1 feedparser 5.2.1 html5lib 0.999999999 httplib2 0.9.2

[...]

but i don't remember what is each module. And effectively one pip show module show me but if i need to make this for x modules, it will be a lot of time :smile:

jeanphi-baconnais avatar Oct 01 '20 15:10 jeanphi-baconnais

Other command, you can change the last word to search other string in "man packages"

while read -r ligne;do;pip show $ligne | grep -E "^Name|^Summary" | sed ':a;N;$!ba;s/\n/ /g' ;done < <(pip list --format=columns | tail -n +3 | cut -d" " -f1) | grep monitor

gives for me

Name: bpytop Summary: Resource monitor that shows usage and stats for processor, memory, disks, network and processes.
Name: psutil Summary: Cross-platform lib for process and system monitoring in Python.

Edit :

function pipsearch () { while read -r ligne ; do pip show $ligne | grep -E "^Name|^Summary" | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g' ; done < <(pip list --format=columns | tail -n +3 | cut -d" " -f1) | grep "$1" ; }
pipsearch monitor

thib1984 avatar Oct 01 '20 15:10 thib1984

Most package managers that I know of, except pip, offer a way to list packages along with their descriptions (and often their versions), and composability usually isn't a problem: getting a list of packages is just a matter of extracting the column with package names.

Anyway, here is my draft solution (using bash, pip, sed, awk, column) for the original suggestion:

$ # List all installed packages, with package name, version, and summary (in fact any property supported by `pip show`), in a table
$ pip show $(pip list | sed -ne '3,$s/ .*$//p') |
  sed -e 's/: /\t/' |
  awk -F'\t' '
    NR==FNR { a[$1]; next }
    $1 in a { if (l) l=l FS; l=l $2 }
    $1 == "---" { print l; l="" }
    END { if (l) print l }
  ' <(printf "%s\n" Name Version Summary) - |
  column -s "$(printf "\t")" -t -N Package,Version,Summary

ackalker avatar Oct 12 '20 23:10 ackalker

@ackalker Can you name a few package managers that have that feature?

Mr-Pepe avatar Oct 19 '22 06:10 Mr-Pepe