Based on A Better Pip Workflow, from a hackernews comment by blaze33:

To keep your file structure with commands and nicely separate your dependencies from your dependencies’ dependencies:

pip freeze -r requirements-to-freeze.txt > requirements.txt

instead of just:

pip freeze > requirements.txt


beware of git urls being replaced by egg names in the process.