Skip to content

Instantly share code, notes, and snippets.

@JetStarBlues
Last active April 26, 2021 19:25
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 JetStarBlues/bfcb07c237b9557e57b278d602e2064b to your computer and use it in GitHub Desktop.
Save JetStarBlues/bfcb07c237b9557e57b278d602e2064b to your computer and use it in GitHub Desktop.
Generating a minimal requirements.txt

Generating a minimal requirements.txt

Option 1 - via pip freeze

  • create a clean virtualenv
  • install only the modules needed to run project
  • run pip freeze to generate a requirements.txt file
    • list of all installed packages and their versions

Option 2 - via pip-compile

  • install pip-tools
    • pip install pip-tools
  • create a requirements.in that lists all pip modules used by the project
# project dependencies
django
gunicorn
  • use pip-compile requirements.in to generate a requirements.txt file
#
# This file is autogenerated by pip-compile
# To update, run:
#
#    pip-compile requirements.in
#
asgiref==3.2.10           # via django
django==3.1               # via -r requirements.in
gunicorn==20.0.4          # via -r requirements.in
pytz==2020.1              # via django
sqlparse==0.3.1           # via django

Sources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment