Skip to content

Divergence from pip-compile when using --upgrade and --upgrade-package #18225

@connor15mcc

Description

@connor15mcc

Summary

Hi folks! Been slowly migrating to use uv's pip-compile compatibility and stumbled across a divergence in behavior when passing both --upgrade (upgrade all packages) and --upgrade-package={pkg}{constraint} (upgrade package {pkg}, subject to {constraint}).

jazzband's pip-compile currently does it's best to respect the intention of both flags -- it considers the additional constraint and maximizes packages upgrades while still satisfying the constraint. It appears that uv simply ignores any additional constraints when alongside --upgrade.

A minimal repro:
FROM --platform=linux/amd64 ghcr.io/astral-sh/uv:0.10.0-debian-slim

WORKDIR /mre

RUN uv venv --quiet && uv pip install --quiet 'pip-tools==7.5.2' 'pip<26'
RUN echo "requests" > requirements.in && \
  echo "requests==2.28.0" > requirements-pipcompile.txt && \
  echo "requests==2.28.0" > requirements-uv.txt

# pip-compile
RUN .venv/bin/pip-compile --quiet requirements.in -o requirements-pipcompile.txt \
    --upgrade --upgrade-package 'requests<2.30.0' && \
  echo "requests version with pip-compile:" && \
  grep "^requests==" requirements-pipcompile.txt

# uv
RUN uv pip compile --quiet requirements.in -o requirements-uv.txt \
    --upgrade --upgrade-package 'requests<2.30.0' && \
  echo "requests version with uv pip compile:" && \
  grep "^requests==" requirements-uv.txt
$ docker build -f ./Dockerfile . --progress=plain --no-cache
...

#8 6.363 requests version with pip-compile:
#8 6.364 requests==2.29.0

...
#9 1.755 requests version with uv pip compile:
#9 1.756 requests==2.32.5

I was curious, so I peeked through the code and found this TODO that seems pertinent.

From my understanding, we DO want uv's pip-compile to be a drop in replacement, so I think it fair to consider this a bug worth fixing! I've been working on a patch that should handle this case (as well as a few related situations with --no-upgrade etc).. I'll link to that from here, if that's ok!

Platform

Ubuntu 24.04 (x84_64), though think this is OS, architecture independent

Version

uv 0.10.7

Python version

Python 3.14.0

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions