A package manager keeps an application's dependency set usable and deployable by resolving declared packages, pinning versions, and excluding development-only packages from production builds. section 8.2.2
Use dependency analysis as an ongoing cleanup workflow:
- List installed packages and compare them with imports used by the application. section 8.2.2
- Remove packages that no longer support code, and separate testing, linting, and debugging tools from production dependencies. section 8.2.2
- Pin the remaining dependency versions so unused packages do not accumulate again. section 8.2.2
Python dependency audit
Run pipreqs against the project to generate requirements-actual.txt, then compare it with the declared requirements. A checkout API team found eight unused packages among 23 declarations; removing them and their indirect dependencies reduced the container image from 2.1GB to 300MB. section 8.2.2
pipreqs /path/to/your/project --savepath requirements-actual.txt
Generate a requirements file from imports with pipreqs. section 8.2.2





