Search code examples
pythondjangocookiecutter-django

How to update requirements?


I would like to know how to update outdated requirements with the multi requirements files setup that cookie cutter uses (base, local, etc...) ?

If i launch a "pip freeze" it will write the requirements in a single file. It will not dispatch them in correct files

Do I miss something ?


Solution

  • You could update all outdated python modules with this command:

    Linux:

    pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U 
    

    Windows (Powershell):

    pip freeze | %{$_.split('==')[0]} | %{pip install --upgrade $_}
    

    After this you have to update your requirements.txt with:

    pip freeze > requirements.txt
    

    If you use Pipenv:

    pipenv shell
    pipenv update
    

    If you use poetry:

    poetry self show --outdated
    poetry update
    

    If you use pip-tools:

    pip-compile --upgrade --dry-run
    pip-compile --upgrade