liveBook · Manning

Package manager

As explained in Fast by Default

A package manager is software that resolves, installs, updates, and removes software packages and their dependencies.

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

How Fast by Default covers it

How deep it goes
Provides a concrete Python audit workflow and production-classification guidance, but does not detail package-manager internals.
Examples
Uses pipreqs, requirements-actual.txt, pip-tools, and a checkout API image reduction from 2.1GB to 300MB.
What it assumes
Assumes dependency declarations and source imports, while teaching how to compare them and classify development tools.
What you can do after
Apply via pipreqs and pip-tools to identify unused packages, minimize production dependencies, and pin versions.
How it connects
Connects package managers with dependencies, production builds, development dependencies, requirements files, and version pinning.

Also explained in

Compare how 6 books explain package manager →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fast by Default. The section links point to the parts of the book it draws on.