Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions lib/pip.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ function dockerPathForWin(options, path) {
* then remove all comments and empty lines, and sort the list which
* assist with matching the static cache. The sorting will skip any
* lines starting with -- as those are typically ordered at the
* start of a file ( eg: --index-url / --extra-index-url )
* start of a file ( eg: --index-url / --extra-index-url ) or any
* lines that start with -f or -i, Please see:
* https://pip.pypa.io/en/stable/reference/pip_install/#requirements-file-format
* @param {string} source requirements
* @param {string} target requirements where results are written
* @param {Object} options
Expand All @@ -297,7 +299,11 @@ function generateRequirementsFile(source, target, options) {
if (req.startsWith('#')) {
// Skip comments
return false;
} else if (req.startsWith('--')) {
} else if (
req.startsWith('--') ||
req.startsWith('-f') ||
req.startsWith('-i')
) {
// If we have options (prefixed with --) keep them for later
prepend.push(req);
return false;
Expand All @@ -309,7 +315,9 @@ function generateRequirementsFile(source, target, options) {
filteredRequirements.sort(); // Sort remaining alphabetically
// Then prepend any options from above in the same order
for (let item of prepend.reverse()) {
filteredRequirements.unshift(item);
if (item && item.length > 0) {
filteredRequirements.unshift(item);
}
}
fse.writeFileSync(target, filteredRequirements.join('\n') + '\n');
}
Expand Down