From 7a63133d2f1f83e129b7d614138d4a82b54ba6f5 Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> Date: Tue, 24 Dec 2024 12:39:20 +0900 Subject: [PATCH] feat(pypi): only query SimpleAPI for pkgs that have shas Later in the code we would only use the results of SimpleAPI if the package has shas, so actually doing these calls is just wasting time, because we would be dropping the results anyway. Work towards #2100 --- CHANGELOG.md | 2 ++ python/private/pypi/parse_requirements.bzl | 1 + tests/pypi/extension/extension_tests.bzl | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb4bcfa8da..fd5d455147 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,8 @@ Unreleased changes template. * Bazel 6 support is dropped and Bazel 7.4.1 is the minimum supported version, per our Bazel support matrix. Earlier versions are not tested by CI, so functionality cannot be guaranteed. +* ({bzl:obj}`pip.parse`) Only query SimpleAPI for packages that have + sha values in the `requirements.txt` file. {#v0-0-0-fixed} ### Fixed diff --git a/python/private/pypi/parse_requirements.bzl b/python/private/pypi/parse_requirements.bzl index 821913d6de..136dba732e 100644 --- a/python/private/pypi/parse_requirements.bzl +++ b/python/private/pypi/parse_requirements.bzl @@ -184,6 +184,7 @@ def parse_requirements( req.distribution: None for reqs in requirements_by_platform.values() for req in reqs.values() + if req.srcs.shas }), ) diff --git a/tests/pypi/extension/extension_tests.bzl b/tests/pypi/extension/extension_tests.bzl index 1caab23cea..5916a27e98 100644 --- a/tests/pypi/extension/extension_tests.bzl +++ b/tests/pypi/extension/extension_tests.bzl @@ -575,7 +575,7 @@ some_pkg==0.0.1 index_url = "pypi.org", index_url_overrides = {}, netrc = None, - sources = ["simple", "some_pkg"], + sources = ["simple"], ), "cache": {}, "parallel_download": False,