├── README.md ├── new-requirements.txt ├── pypi-info.sh └── requirements.txt /README.md: -------------------------------------------------------------------------------- 1 | # pypi-info-generator 2 | 3 | Script to auto generate Python package info on requirements.txt 4 | 5 | ## prerequisites 6 | 7 | - [jq is a lightweight and flexible command-line JSON processor.](https://stedolan.github.io/jq/) 8 | 9 | **OSX** 10 | 11 | brew install jq 12 | 13 | **Ubuntu** 14 | 15 | sudo apt-get install jq 16 | 17 | ## Installation 18 | 19 | ```bash 20 | curl -L https://raw.githubusercontent.com/hanksudo/pypi-info-generator/master/pypi-info.sh -o ~/bin/pypi-info && chmod +x ~/bin/pypi-info 21 | ``` 22 | 23 | ## Usage 24 | 25 | ```bash 26 | pypi-info requirements.txt 27 | ``` 28 | 29 | **input file: requirements.txt** 30 | 31 | ``` 32 | Pygments==2.0.2 33 | simplejson==3.3.1 34 | oauth2client 35 | ``` 36 | 37 | **output file: new-requirements.txt** 38 | 39 | ``` 40 | # Pygments is a syntax highlighting package written in Python. 41 | # http://pygments.org/ 42 | Pygments==2.0.2 43 | 44 | # Simple, fast, extensible JSON encoder/decoder for Python 45 | # http://github.com/simplejson/simplejson 46 | simplejson==3.3.1 47 | 48 | # OAuth 2.0 client library 49 | # http://github.com/google/oauth2client/ 50 | oauth2client 51 | ``` 52 | -------------------------------------------------------------------------------- /new-requirements.txt: -------------------------------------------------------------------------------- 1 | # Pygments is a syntax highlighting package written in Python. 2 | # http://pygments.org/ 3 | Pygments==2.0.2 4 | 5 | # Simple, fast, extensible JSON encoder/decoder for Python 6 | # http://github.com/simplejson/simplejson 7 | simplejson==3.3.1 8 | 9 | # OAuth 2.0 client library 10 | # http://github.com/google/oauth2client/ 11 | oauth2client 12 | 13 | -------------------------------------------------------------------------------- /pypi-info.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () 4 | { 5 | echo 'Usage :' 6 | echo "\t$0 requirements.txt" 7 | exit 8 | } 9 | 10 | if [ "$#" -ne 1 ] 11 | then 12 | usage 13 | fi 14 | 15 | grep -Ev '^$|#' $1 | while read -r line ; do 16 | package=`echo $line | awk -F'==' '{print $1}'` 17 | curl -L https://pypi.python.org/pypi/$package/json 2>/dev/null | jq -r '.info | .summary + "\n" + .home_page' | sed 's/^/# /' | tee -a new-$1 18 | echo $line | tee -a new-$1 19 | echo "" | tee -a new-$1 20 | done 21 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Pygments==2.0.2 2 | simplejson==3.3.1 3 | oauth2client --------------------------------------------------------------------------------