Skip to content

Recognize uv pip system installs in Dockerfile inputs - #625

Merged
patrickballard merged 6 commits into
wheelgap:mainfrom
kunalkshah1:fix/docker-uv-pip-install
Nov 21, 2026
Merged

patrickballard merged 6 commits into
wheelgap:mainfrom
kunalkshah1:fix/docker-uv-pip-install

Conversation

@kunalkshah1

Copy link
Copy Markdown
Contributor

Closes #596

What this changes

Read uv pip install --system for requirements-file inputs, with the two cache flags, and identify uv in the RUN diagnostic. Recognize the documented external COPY of the uv and optional uvx binaries. Refuse unsupported flags and potentially active uv configuration files.

Tests compare the Dockerfile and direct requirements reports, exercise both binary destinations and verify line-specific refusals. All four new parity cases fail on the original source.

AI tools used: Codex

Ruff formatting and lint, mypy, and full pytest on macOS with Python 3.14 (5,188 passed, 3 skipped). The Unreleased entry will be added with the PR number.

@patrickballard

Copy link
Copy Markdown
Collaborator

Thanks @kunalkshah1, this looks good overall: uv pip install --system -r FILE is read, the usual COPY --from=ghcr.io/astral-sh/uv of the binaries is recognised, and other uv flags or a copied uv.toml / pyproject.toml are refused with their line. Comparing the report with a direct requirements check in the tests is a good touch.

It touches the same parts of dockerfile.py and cli.py as your other --dockerfile-inputs PRs (#621, #622, #625, #626, #630), so Patrick will sort out the merge order and any conflicts between them.

CI is green on this commit.

#596 is a help wanted issue, so Patrick will review and merge this one himself. Nothing more needed from you for now.

(Review assisted by Claude.)

patrickballard and others added 2 commits November 21, 2026 10:52
uv ignores a Requires-Python upper bound that makes pip refuse a pin (uv 0.13.1 installs sktime==0.20.0 on Python 3.13, pip finds no matching distribution), so a file read from RUN uv pip install was reported missing for a build that succeeds. Such files now go through the uv.lock policy (restore_uv_python_files), with the usual pip_refuses note. uv also picks the format of -r FILE by its name, so only *.txt and *.in files are read for uv. Docs mark the feature as after 0.13.0.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@patrickballard

Copy link
Copy Markdown
Collaborator

Thanks @kunalkshah1! The flag handling is right: only --system, the cache flags and -r are read, everything else is refused with its line, and a copied uv.toml or pyproject.toml is refused as #596 asks.

The issue itself was wrong on one point (it said to check the file as a pip requirements file), so we've made these changes:

  • A file installed by uv pip install is checked as uv installs it. uv ignores Requires-Python upper bounds, so a pin pip refuses (we checked sktime==0.20.0 on 3.13 with both tools) gets uv's answer with the "pip refuses" note.
  • For uv, only -r files named *.txt or *.in are read, because uv reads other names as locks, scripts or projects.
  • Tests for both, plus refusal rows for uv sync, uv add, uv pip sync, --python and --index-url. Docs marked "after 0.13.0".

One more change is coming before merge: an unpinned requirement under uv will be refused for now, since uv and pip can pick different versions for a range and wheelgap would be guessing. This one merges last of the four Dockerfile PRs, with main merged in, and gets its final review then.

(Review assisted by Claude.)

patrickballard and others added 2 commits November 21, 2026 11:57
…t be pinned

main gained -c FILE and harmless pip flags (wheelgap#622), verified includes (wheelgap#621),
.dockerignore rules (wheelgap#626), install provenance (wheelgap#630), uv's Requires-Python
lower-bound rule (wheelgap#623) and MCP wording (wheelgap#624) since this branch was written.

_pip_install_files returns (files, constraints, prefer_binary, uv) and has one
flag loop with the uv branch first. On a uv line only uv's own flags are read:
--system, -r/--requirements, -c/--constraints, --no-cache, --no-cache-dir,
--upgrade/-U and --quiet/-q (checked against `uv pip install --help`, 0.13.1).
pip's --no-input, --root-user-action and --prefer-binary don't exist in uv, and
--disable-pip-version-check only warns there, so they are refused.

A uv line's files are found by the same copied_requirements closure as pip's,
so the ignore rules and the include checks apply. Three things are uv's own:
- every requirement must be pinned with == (through includes; a pin from a
  constraints file counts), using the gate --prefer-binary already had, and
  --deps is refused: wheelgap resolves a range as pip does, and uv can pick
  another release;
- a -r inside a constraints file is refused: pip installs what it names and uv
  only constrains with it (uv 0.13.1 against pip 26.2);
- included and -c files must be named *.txt or *.in, like the -r file.
A file installed by pip on one line and uv on another is refused, and a caller
that doesn't pass uv_installs gets an error rather than pip's answer.

cli.py: the stderr note keeps main's list of every file read and says which
installer ran; uv-installed files get restore_uv_python_files, as a uv.lock
with --online does, so the pip_refuses note is main's.

docs/cli.md has one paragraph for uv; CHANGELOG keeps every bullet once, this
PR's first, reworded.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The requirements reader follows pip for option lines inside a file, and uv
reads them by its own rules: with --extra-index-url uv takes the first index
that has the package where pip takes the best file of them all, and
--no-binary / --only-binary combine differently (uv 0.13.9). A uv-installed
file with such a line got pip's answer.

Every file a uv line reads (the -r file, the RUN line's -c file, and every
file they include) may now hold only requirements and plain `-r FILE` /
`-c FILE` lines; any other option line is an error naming the option and the
file, never its value, so an index URL with credentials isn't echoed. A
requirement with its own --hash is not an option line and is still read. pip
lines are unchanged.

The refusal for a COPY that brings a uv.toml or pyproject.toml before a uv
line now says what to do about it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@patrickballard
patrickballard merged commit ab4a589 into wheelgap:main Nov 21, 2026
13 checks passed
@patrickballard

Copy link
Copy Markdown
Collaborator

Merged, thanks @kunalkshah1! That is all four of your Dockerfile PRs in, combined: pip flags and -c, verified includes, .dockerignore rules, and now uv pip install.

The issue was wrong to say a uv-installed file should be checked as pip would, so this one changed the most before merge. Each point was tested with real uv and pip:

  • The answer follows uv: its Requires-Python rule, and only files named *.txt or *.in.
  • Under uv every requirement must be pinned with ==, and --deps is refused, because uv and pip can pick different versions for a range.
  • pip-only flags are refused on a uv line. uv's own -c, -U and -q are read.
  • A -r inside a constraints file is refused under uv: pip installs what it names, uv only constrains with it.
  • An option line in the file (--extra-index-url, --no-binary) is refused under uv, which reads those by different rules. The message never echoes an index URL.
  • The message for a copied uv.toml or pyproject.toml now says what to do.

(Reply assisted by Claude.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--dockerfile-inputs: read RUN uv pip install --system -r FILE

2 participants