Skip to content

Commit c4e4a4f

Browse files
authored
Improve the error message shown for legacy Celery (#1718)
pip 24.1+ rejects packages that use invalid versions in their metadata (such as Celery older than v5.2.1). We now annotate such failures with additional help text, mentioning the package needs to be upgraded, and link to the changelog entry which has additional advice: https://devcenter.heroku.com/changelog-items/3073 GUS-W-17415804.
1 parent 07005f2 commit c4e4a4f

File tree

5 files changed

+47
-5
lines changed

5 files changed

+47
-5
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
4848
HEROKU_API_USER: ${{ secrets.HEROKU_API_USER }}
4949
HEROKU_DISABLE_AUTOUPDATE: 1
50-
PARALLEL_SPLIT_TEST_PROCESSES: 70
50+
PARALLEL_SPLIT_TEST_PROCESSES: 75
5151
RSPEC_RETRY_RETRY_COUNT: 2
5252
steps:
5353
- name: Checkout

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## [Unreleased]
44

5+
- Improved the error message shown when pip install fails due to pip rejecting a package with invalid version metadata. ([#1718](https://github.com/heroku/heroku-buildpack-python/pull/1718))
56

67
## [v270] - 2024-12-10
78

bin/warnings

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
gdal-missing() {
3+
show-warnings() {
44
# shellcheck disable=SC2154 # TODO: Env var is referenced but not assigned.
55
if grep -qi 'Could not find gdal-config' "${WARNINGS_LOG}"; then
66
output::error <<-'EOF'
@@ -10,8 +10,19 @@ gdal-missing() {
1010
https://github.com/heroku/heroku-geo-buildpack
1111
EOF
1212
fi
13-
}
1413

15-
show-warnings() {
16-
gdal-missing
14+
# shellcheck disable=SC2154 # TODO: Env var is referenced but not assigned.
15+
if grep -qi 'Please use pip<24.1 if you need to use this version' "${WARNINGS_LOG}"; then
16+
output::error <<-'EOF'
17+
Error: One of your dependencies contains broken metadata.
18+
19+
Newer versions of pip reject packages that use invalid versions
20+
in their metadata (such as Celery older than v5.2.1).
21+
22+
Try upgrading to a newer version of the affected package.
23+
24+
For more help, see:
25+
https://devcenter.heroku.com/changelog-items/3073
26+
EOF
27+
fi
1728
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
celery==5.2.0

spec/hatchet/pip_spec.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,33 @@
285285
end
286286
end
287287
end
288+
289+
context 'when requirements.txt contains an old version of Celery with invalid metadata' do
290+
let(:app) { Hatchet::Runner.new('spec/fixtures/requirements_legacy_celery', allow_failure: true) }
291+
292+
it 'outputs instructions for how to resolve the build failure' do
293+
app.deploy do |app|
294+
expect(clean_output(app.output)).to include(<<~OUTPUT)
295+
remote: ERROR: No matching distribution found for celery==5.2.0
296+
remote:
297+
remote: ! Error: One of your dependencies contains broken metadata.
298+
remote: !
299+
remote: ! Newer versions of pip reject packages that use invalid versions
300+
remote: ! in their metadata (such as Celery older than v5.2.1).
301+
remote: !
302+
remote: ! Try upgrading to a newer version of the affected package.
303+
remote: !
304+
remote: ! For more help, see:
305+
remote: ! https://devcenter.heroku.com/changelog-items/3073
306+
remote:
307+
remote:
308+
remote: ! Error: Unable to install dependencies using pip.
309+
remote: !
310+
remote: ! See the log output above for more information.
311+
remote:
312+
remote: ! Push rejected, failed to compile Python app.
313+
OUTPUT
314+
end
315+
end
316+
end
288317
end

0 commit comments

Comments
 (0)