Repository navigation
fix: read includes of a symlinked requirements file from the link's folder - #618
Conversation
|
Thanks @Dikshant-Neupane, this looks good overall: includes now resolve against the folder the file was named in, as pip does, while the resolved path stays the identity for the "already read" and cycle checks, and the PR says clearly why you chose that. The tests cover every case the issue lists. One thing to flag:
#604 is a (Review assisted by Claude.) |
… tests pip 26.3 compares the include's os.path.abspath with the chain, so one shared file linked into two folders can be on the chain under both names without being a cycle; the resolved-path check refused that layout with 'pip refuses this' although pip installs it. The already-read identity stays the resolved path. relative_path() resolves links again, as on main: git keeps a link as a link, so an annotation under the link's path has no lines to show, and other inputs' annotations stay as they were. The two tests that failed on Windows compared a path with its repr and made a link with forward slashes. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Thanks @Dikshant-Neupane! The core change matches pip: we checked real pip 26.3 on a symlinked file, a symlinked folder and a link to a link, and it resolves includes against the folder the file was named in each time. Adding to the earlier review, we've made these changes so it can go in:
Please name the AI tool in the PR description, if one helped. It'll merge once a final review passes. (Review assisted by Claude.) |
# Conflicts: # CHANGELOG.md
|
Merged, thanks @Dikshant-Neupane! The final review ran real pip 26.3 on eleven symlink layouts, and wheelgap reads the same packages in each. If you would like another, tracker#213 is open and unclaimed: the repo checker gives an unhelpful error for a package name or a GitLab URL typed in the box. (Reply assisted by Claude.) |
CHANGELOG keeps both bullets, this PR's first. Co-Authored-By: Claude Fable 5.2 <[email protected]>
CHANGELOG keeps both bullets, this PR's first. Co-Authored-By: Claude Fable 5.2 <[email protected]>
CHANGELOG conflict only: both bullets kept, this PR first. Co-Authored-By: Claude Fable 5.2 <[email protected]>
CHANGELOG conflict only: both bullets kept, this PR first. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Thank you for the reviews and for merging it, and for the extra fixes and the real pip checks on the symlink layouts. I learned a lot from how you handled the cycle check and the annotations. Please let me know if there is another issue I can help with. |
…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]>
main gained wheelgap#618, which rewrote the first lines of requirement_lines(): a file is read through the folder it was named in and the already-read set holds resolved paths. The merged scanner keeps this PR's per-role seen (a -r inside a constraints file gives requirements, a constraints file's own lines give none) with that path handling, as sources._read_requirements has both. One test covers the two together: a symlinked requirements file whose includes go -c then -r. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Closes #604.
pip resolves a relative -r against the folder of the file as it was named, with no symlink resolution. wheelgap resolved symlinks first, so an include in a symlinked requirements file was read from the folder the link points into. With a shared reqs.txt linked into several service folders, each with its own base.txt, wheelgap checked other packages than pip installs.
This reads every requirements file through the folder it was named in (os.path.abspath, no symlink resolution), so includes resolve against the link's folder, as pip does.
The loop and already-read identity stays the resolved path, so a file reached by two names is still read once and a cycle through a link is still refused. Pip uses the abspath for that identity too, which would read such a file twice and list its packages twice; the resolved identity keeps the single-read behaviour. The cycle error names the file as written, as pip does.
--github-annotations now annotates the file pip reads, and --dockerfile-inputs still refuses symlinks in a build context.
The tracker check from the issue (tests/test_check_driver.py and tests/test_check_parity.py) is not run here, the tracker repo is not on this box. The missing-include error now names the as-named path, which is what needs() reads, so that path should still work.
AI assistance was used to prepare this PR, and I reviewed the changes before opening it.