Skip to content

Commit

Permalink
Stop filtering out pip's "Requirement already satisfied" lines
Browse files Browse the repository at this point in the history
Since while removing them makes the install logs slightly shorter,
it hides what is happening and makes it harder to see what package
version a historic build may have been using from the logs alone.
For example, when comparing a last successful build to a newly
failing build.

This now matches the behaviour for our other supported package
managers, where we don't filter out install lines relating to already
installed/cached packages.

As a compromise, we still edit the lines slightly, to remove the redundant
site-packages path information, which would otherwise cause each
package message to span multiple lines.
  • Loading branch information
edmorley committed Feb 24, 2025
1 parent 3033b54 commit f8a2709
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

- Stopped filtering out pip's `Requirement already satisfied:` lines when installing dependencies. ([#1765](https://github.com/heroku/heroku-buildpack-python/pull/1765))
- Improved the error messages shown if installing pip/Poetry/Pipenv fails. ([#1764](https://github.com/heroku/heroku-buildpack-python/pull/1764))
- Stopped installing pip into Poetry's virtual environment. ([#1761](https://github.com/heroku/heroku-buildpack-python/pull/1761))

Expand Down
4 changes: 3 additions & 1 deletion lib/pip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ function pip::install_dependencies() {
# We only display the most relevant command args here, to improve the signal to noise ratio.
output::step "Installing dependencies using '${pip_install_command[*]}'"

# The sed usage is to reduce the verbosity of output lines like:
# "Requirement already satisfied: typing-extensions==4.12.2 in /app/.heroku/python/lib/python3.13/site-packages (from -r requirements.txt (line 5)) (4.12.2)"
# shellcheck disable=SC2310 # This function is invoked in an 'if' condition so set -e will be disabled.
if ! {
"${pip_install_command[@]}" \
Expand All @@ -116,7 +118,7 @@ function pip::install_dependencies() {
--progress-bar off \
--src='/app/.heroku/python/src' \
|& tee "${WARNINGS_LOG:?}" \
|& sed --unbuffered --expression '/Requirement already satisfied/d' \
|& sed --unbuffered --expression 's# in /app/.heroku/python/lib/python.*/site-packages##' \
|& output::indent
}; then
# TODO: Overhaul warnings and combine them with error handling.
Expand Down
7 changes: 5 additions & 2 deletions spec/hatchet/ci_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,19 @@
REGEX

test_run.run_again
expect(clean_output(test_run.output)).to include(<<~OUTPUT)
expect(clean_output(test_run.output)).to match(Regexp.new(<<~REGEX, Regexp::MULTILINE))
-----> Python app detected
-----> Using Python #{DEFAULT_PYTHON_MAJOR_VERSION} specified in .python-version
-----> Restoring cache
-----> Using cached install of Python #{DEFAULT_PYTHON_FULL_VERSION}
-----> Installing pip #{PIP_VERSION}
-----> Installing dependencies using 'pip install -r requirements.txt -r requirements-test.txt'
Requirement already satisfied: typing-extensions==.+
Requirement already satisfied: pytest==.+
.+
-----> Skipping Django collectstatic since the env var DISABLE_COLLECTSTATIC is set.
-----> Running bin/post_compile hook
OUTPUT
REGEX
end
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/hatchet/pip_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
remote: -----> Using cached install of Python #{DEFAULT_PYTHON_FULL_VERSION}
remote: -----> Installing pip #{PIP_VERSION}
remote: -----> Installing dependencies using 'pip install -r requirements.txt'
remote: Requirement already satisfied: typing-extensions==4.12.2 (from -r requirements.txt (line 5)) (4.12.2)
remote: -----> Inline app detected
OUTPUT
end
Expand Down

0 comments on commit f8a2709

Please sign in to comment.