From 547e33ccb76aff7e4c8801bf2446f94e85332b4b Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Sun, 14 Jul 2024 11:58:36 -0400 Subject: [PATCH] pypi: allow source wheels as resources Signed-off-by: William Woodruff --- Library/Homebrew/utils/pypi.rb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/utils/pypi.rb b/Library/Homebrew/utils/pypi.rb index db9f6337e7..54b41fbdf6 100644 --- a/Library/Homebrew/utils/pypi.rb +++ b/Library/Homebrew/utils/pypi.rb @@ -73,12 +73,22 @@ module PyPI return end - sdist = json["urls"].find { |url| url["packagetype"] == "sdist" } - return if sdist.nil? + dist = json["urls"].find do |url| + url["packagetype"] == "sdist" + end + + # If there isn't an sdist, we use the first source wheel. + if dist.nil? + dist = json["urls"].find do |url| + url["filename"].end_with?("-none-any.whl") + end + end + + return if dist.nil? @pypi_info = [ - PyPI.normalize_python_package(json["info"]["name"]), sdist["url"], - sdist["digests"]["sha256"], json["info"]["version"] + PyPI.normalize_python_package(json["info"]["name"]), dist["url"], + dist["digests"]["sha256"], json["info"]["version"] ] end