pip is Python’s package installer and dependency-management tool. Projects record dependencies in requirements.txt or pyproject.toml, then audit them against the imports used by the application. section 8.2.2
Use pip-related workflows to keep production dependencies accurate and compact:
- Run pipreqs against the project to generate requirements-actual.txt from source-code imports, then compare it with declared requirements. section 8.2.2
- Classify testing, linting, and debugging packages as development dependencies so production builds can exclude them. section 8.2.2
- Use pip-tools to resolve declared dependencies and pin versions, limiting unused-package accumulation over time. section 8.2.2
- Check unexpectedly large wheel files for compiled binaries and consider lighter alternatives. section 8.2.2
Removing unused checkout API dependencies
A checkout API team compared pipreqs output with 23 declared dependencies and found eight unused packages, including obsolete feature dependencies and development tools. Removing them and their indirect dependencies reduced the container image by 40MB, from 2.1GB to 300MB. section 8.2.2
pipreqs /path/to/your/project --savepath requirements-actual.txt
Run pipreqs /path/to/your/project --savepath requirements-actual.txt to generate an import-based dependency list. section 8.2.2




