Safeguard
Developer Tools•

How do I preview a Python dependency upgrade before installing it?

Pip's dry-run mode and JSON install report show what an upgrade would change before anything is installed. How to use them before merging a fix.

Safeguard Security Team
4 min read

Run pip install with the dry-run flag and the report option. Pip resolves the requirements, lists exactly which packages and versions it would install, and writes a JSON report, without touching your environment. Diff that report against the current one to see what a security upgrade really changes.

Why preview at all

A fix pull request that says "bump one package" often changes more than one line of reality. The resolver may pull a new version of a shared library, drop a package, or add one. Reading the resolved set before you install is cheaper than debugging it after.

The pip documentation describes the two pieces. The dry-run flag tells pip not to install anything and only print what would be done. The install report option generates a JSON report of what pip has installed, and the docs state that combined with dry-run and the ignore-installed flag it can resolve a set of requirements without actually installing them. The report can go to a file or to standard output when combined with the quiet flag.

Steps

  1. Resolve the current requirements into a report and save it as before.json.
  2. Edit the requirement or constraint to the fixed version.
  3. Resolve again into after.json.
  4. Compare the two files.
  5. Review every package whose version, presence or source changed.
python -m pip install --dry-run --ignore-installed --quiet \
  --report before.json -r requirements.txt

Run the same command after the edit with a different report name. A plain text diff of the two JSON files is enough for a first pass, or extract the name and version pairs with a short script.

What to look for in the diff

Change in the reportWhat it meansAction
Target package moved to the fixed versionThe fix appliesExpected
A package you did not touch changed versionResolver side effectRead its changelog
A new package appearedNew dependency pathReview it like a new dependency
A package disappearedA parent dropped itCheck nothing imports it directly
Version unchangedA parent or pin blocks the fixFind the cap before merging

The last row matters most for security work. A pull request that claims to fix a vulnerability but leaves the version unchanged in the resolved set has fixed nothing.

Pair it with a real check

A dry run proves what pip would choose. It does not prove your code still works. After you install for real, run pip check, which verifies that installed packages have compatible dependencies and exits with a non-zero code when a requirement is missing or has the wrong version. Then run your tests.

Keep the before and after reports with the pull request. They are a small, honest record of the change, useful for reviewers and for anyone asking later what moved.

Try it yourself

Click through it at your own pace, or open it full screen. Look at how the dependency list is organised, then imagine diffing two of those lists.

Where Safeguard fits

Safeguard scans dependencies, runs reachability analysis to show which findings your code can actually reach, and can open fix pull requests through autonomous remediation. That last feature is off by default and every category starts on Manual, so a person approves each change. You can try a free scan on a repository first.

Quick check

Does dry-run install anything?

No. Pip prints what it would do and, with the report option, writes the resolved set to JSON.

What does pip check add?

It verifies that installed packages have compatible dependencies and returns a non-zero exit code when they do not.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.