2

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 ?

  • Unfortunately, I fear you have to handle this by hand. When you install a new package, remember to add it to the correct requirements file with the version you want. It's also a bit cleaner because `pip freeze` tends to write sub-dependencies (dependencies of your dependencies). – frankie567 Sep 25 '19 at 11:55
  • Pipenv might help you solve that problem but still need to manually migrate to use it. https://github.com/pypa/pipenv – Toan Quoc Ho Sep 25 '19 at 12:00
  • So the process is: - pip list --oudated to see upgrade candidates - pip install --upgrade - pip freeze > requirements.txt to freeze - split requirements.txt entries by hand in correct files - get rid of requirements.txt before commit :) – Arnaud Lecat Sep 25 '19 at 13:38
  • This is why I'm not a huge fan of having different `requirements` files, like they do in `cookiecutter-django`. Maybe you can get inspiration from this approach: https://www.kennethreitz.org/essays/a-better-pip-workflow – frankie567 Sep 25 '19 at 14:26

2 Answers2

1

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
ikreb
  • 2,133
  • 1
  • 16
  • 35
1

pip-update-requirements updates the packages in a requirements.txt-like file (whatever its actual name is):

pip install pur
pur -r requirements/local.txt

Pur does not modify your environment or installed packages, it only modifies your requirements.txt-like file.

It will also update nested requirements files, unless otherwise indicated.

Quique
  • 909
  • 10
  • 8