Skip to content

fix: Warn only when all SHAs fail to match a requirement #2922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions python/private/pypi/parse_requirements.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ def _add_dists(*, requirement, index_urls, logger = None):
sdist = maybe_sdist
continue

if logger:
logger.warn(lambda: "Could not find a whl or an sdist with sha256={}".format(sha256))
if logger and (len(whls) == 0 and sdist == None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vars are undefined here. What is that you are trying to achieve?

Copy link
Author

@stefanpenner stefanpenner May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vars are undefined here.

@aignas maybe I'm missing something, but whls & sdist appear to be defined at:

https://github.com/bazel-contrib/rules_python/pull/2922/files#diff-cea723aaf48fab4acf923b65c3b4fe6c9bb5dec514cacf7c20fb3f92116151d3R311

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sha256 in the log call isn't defined, let me fix that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry, somehow I missed it.

However, the intention of the check though was to tell the users that something is wrong andthat the lock file contains hashes that we could not find on the index.

What would be the use case where such behaviour is not desired?

logger.warn(lambda: "Could not find a whl or an sdist with sha256={} for requirement={}".format(sha256, requirement))

yanked = {}
for dist in whls + [sdist]:
Expand Down