Repository navigation
Read pip install flags and constraints from Dockerfile RUN - #622
Merged
patrickballard merged 5 commits intoNov 21, 2026
Merged
Conversation
…s source, and read -c FILE as -r FILE is read A requirements file installed with -c FILE was parsed outside load_file, so its source lost its kind and path (--fix and --github-annotations go by both). A symlinked requirements or constraints file named as a COPY source was newly refused (Docker follows it, and main reads it), as was every file when the build context folder itself is a symlink. --root-user-action took any value, though pip exits on one other than warn or ignore. The refusal message now lists the flags read, the stderr note names the -c files, a caller that doesn't take the constraints gets an error instead of unconstrained requirements, and a -r inside a constraints file keeps its packages. Docs mark the new flags as after 0.13.0. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This was referenced Nov 21, 2026
CHANGELOG.md: both sides' bullets kept, this PR's first. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Collaborator
|
Thanks @kunalkshah1! The design matches #595: the flags that don't change which files pip picks are read, We've made these changes so it can go in:
This one goes first of your four Dockerfile PRs, since they all change the same block; we'll merge main into the others in turn. It'll merge once a final review passes. (Review assisted by Claude.) |
# Conflicts: # CHANGELOG.md
Collaborator
|
Merged, thanks @kunalkshah1! The final review ran real pip 26.3 with each accepted flag and got the same install report as a plain (Reply assisted by Claude.) |
patrickballard
added a commit
to kunalkshah1/wheelgap
that referenced
this pull request
Nov 21, 2026
…s, pin gate through includes main now has wheelgap#622 (harmless pip flags, -c FILE on the RUN line, the --prefer-binary gate) and wheelgap#618 (a symlinked file's includes are read from the link's folder). Both PRs rewrote the same block of dockerfile.py, so this reconciles them rather than taking a side: - copied_requirements (the wheelgap#622 closure that resolves -r FILE and -c FILE) now finds the file with _find_copied_file and verifies its includes with _check_includes, in place of the _has_include refusal. That covers -c files too: a -r inside a constraints file is read as requirements, so its packages are installed and the file must be the one the image has. `includes` is filled for constraints files as well as requirements files. - The --prefer-binary gate parses the file as load_inputs will, with the line's -c files and through every include, so an unpinned requirement in an included file (or in a -r inside a -c file) is refused and the message names that file. A requirement that a constraint pins with == counts as pinned. --deps is still refused, before anything is parsed. - dockerfile_requirements takes includes=, constraints= and dependencies=; the CLI passes all three and the stderr note lists the requirements file, its includes, each -c file and that file's includes. - wheelgap#622's test that a -c file with a nested -c is refused now expects the include to be followed through the image (refused when it isn't copied), and new tests cover a -r inside a RUN-line -c file, --prefer-binary with an unpinned requirement in an included file, and a chain that mixes a RUN-line -c with an in-file -c. - CHANGELOG keeps both bullets; docs/cli.md describes includes and -c files in one paragraph. Co-Authored-By: Claude Fable 5.2 <[email protected]>
patrickballard
added a commit
to kunalkshah1/wheelgap
that referenced
this pull request
Nov 21, 2026
CHANGELOG.md conflicted with wheelgap#622's bullet: both kept, this PR's first. Co-Authored-By: Claude Fable 5.2 <[email protected]>
patrickballard
added a commit
to kunalkshah1/wheelgap
that referenced
this pull request
Nov 21, 2026
CHANGELOG.md conflicted with wheelgap#622's bullet: both kept, this PR's first. Co-Authored-By: Claude Fable 5.2 <[email protected]>
patrickballard
added a commit
to kunalkshah1/wheelgap
that referenced
this pull request
Nov 21, 2026
patrickballard
added a commit
to kunalkshah1/wheelgap
that referenced
this pull request
Nov 21, 2026
main gained wheelgap#622 (pip flags, -c FILE on the RUN line, the --prefer-binary gate), wheelgap#621 (verified -r/-c includes) and wheelgap#630 since this branch was written. dockerfile.py: main moved the COPY lookup into _find_copied_file, called by the copied_requirements closure and by _check_includes. The ignore rules are now a required argument of _find_copied_file and _check_includes and reach _copied_file from both, so a file that .dockerignore leaves out under a folder COPY is refused with the rule named whether it is the installed file, a -c file on the RUN line, or a -r/-c inside either. Without this an excluded include would have been read from disk although the image doesn't have it. The old "a .dockerignore is refused" loop stays deleted (main still had it), and the merged docstring no longer lists a .dockerignore among the refusals. tests: both sides' new tests are kept; the nested-includes test keeps wheelgap#621's assertions and this branch's removal of its .dockerignore tail. New tests for the interaction: an excluded include (one and two levels down), an excluded -c file, an excluded -r inside the -c file, the same under --prefer-binary, an include a later ! rule puts back (and a later rule takes out again), a file COPY naming an excluded source, and the CLI looking nothing up. docs/cli.md: the ignore-file paragraph says included and constraints files are covered. CHANGELOG: every bullet once, this PR's first. Co-Authored-By: Claude Fable 5.2 <[email protected]>
patrickballard
added a commit
to kunalkshah1/wheelgap
that referenced
this pull request
Nov 21, 2026
…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]>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #595
What this changes
Recognize the documented pip diagnostics and cache flags, plus
--upgradeand per-RUN constraints, when reading Dockerfile inputs. Follow constraint files through the same COPY and WORKDIR rules as requirements files and pass them to the usual requirements parser. Allow--prefer-binaryonly when the requirements are exactly pinned and the check does not resolve dependencies.Tests cover accepted flags, refusal of flags that change resolution, missing and symlinked constraints, and parity with the same constraints specified inside the requirements file.
AI tools used: Codex
Checks
Ruff formatting and lint, mypy, and full pytest on macOS with Python 3.14 (5,196 passed, 3 skipped). The Unreleased entry will be added with the PR number.