Skip to content

Instantly share code, notes, and snippets.

@ddugovic
Created July 2, 2020 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddugovic/82029aecc011c0fa4bac3ede32821586 to your computer and use it in GitHub Desktop.
Save ddugovic/82029aecc011c0fa4bac3ede32821586 to your computer and use it in GitHub Desktop.
Generate requirements.txt from pipfile.lock
#
# https://github.com/pypa/pipenv/issues/3493#issuecomment-651148507
cat Pipfile.lock \
| grep -B1 '"hashes"\|"version": ' \
| grep -v '"markers": \|"hashes": ' \
| grep ": {\|version" \
| sed -e 's/: {$//g' \
| tr '\n' ',' | tr -s ' ' ' ' \
| sed -e 's/, "version": "//g;s/", "/ /g;s/"//g;s/,//g' \
| tr ' ' '\n' \
| grep -v "^$" > requirements.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment