Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions news/3906.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(pypi) correctly parse the `index_url` for each wheel so that the source registry is forwarded to
the {obj}`whl_library`. This is so that the `purl` for `package_metadata` can be correctly
constructed.
9 changes: 8 additions & 1 deletion python/private/pypi/parse_requirements.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ def _parse_uv_lock_json(uv_lock, all_platforms, logger, extra_pip_args = None, p
"versions": {},
})
entry["versions"][version] = None
source = pkg.get("source") or {}
registry = (source.get("registry") or "").rstrip("/")
if registry.startswith("http://") or registry.startswith("https://"):
index_url = "{}/{}".format(registry, norm_name.replace("_", "-"))
else:
index_url = ""
entry["index_url"] = index_url

pkg_extras = sorted(extras_map.get(name, []))
extra_str = "[{}]".format(",".join(pkg_extras)) if pkg_extras else ""
Expand Down Expand Up @@ -287,7 +294,7 @@ def _parse_uv_lock_json(uv_lock, all_platforms, logger, extra_pip_args = None, p
name = norm_name,
is_exposed = True,
is_multiple_versions = len(versions) > 1,
index_url = "",
index_url = info["index_url"],
srcs = info["resolved_srcs"],
)
ret.append(item)
Expand Down
36 changes: 18 additions & 18 deletions tests/pypi/parse_requirements/parse_requirements_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ def _test_uv_lock_consistent(env):
env.expect.that_collection(got).contains_exactly([
struct(
name = "foo",
index_url = "",
index_url = "https://pypi.org/simple/foo",
is_exposed = True,
is_multiple_versions = False,
srcs = [
Expand Down Expand Up @@ -1080,7 +1080,7 @@ def _test_uv_lock_primary_source(env):
env.expect.that_collection(got).contains_exactly([
struct(
name = "foo",
index_url = "",
index_url = "https://pypi.org/simple/foo",
is_exposed = True,
is_multiple_versions = False,
srcs = [
Expand Down Expand Up @@ -1108,7 +1108,7 @@ def _test_uv_lock_primary_source_multiple_versions(env):
env.expect.that_collection(got).contains_exactly([
struct(
name = "foo",
index_url = "",
index_url = "https://pypi.org/simple/foo",
is_exposed = True,
is_multiple_versions = True,
srcs = [
Expand Down Expand Up @@ -1146,7 +1146,7 @@ def _test_uv_lock_primary_source_with_extras(env):
env.expect.that_collection(got).contains_exactly([
struct(
name = "foo",
index_url = "",
index_url = "https://pypi.org/simple/foo",
is_exposed = True,
is_multiple_versions = False,
srcs = [
Expand Down Expand Up @@ -1174,7 +1174,7 @@ def _test_uv_lock_primary_source_includes_virtual(env):
env.expect.that_collection(got).contains_exactly([
struct(
name = "foo",
index_url = "",
index_url = "https://pypi.org/simple/foo",
is_exposed = True,
is_multiple_versions = False,
srcs = [
Expand Down Expand Up @@ -1212,7 +1212,7 @@ def _test_uv_lock_cross_consistent(env):
env.expect.that_collection(got).contains_exactly([
struct(
name = "foo",
index_url = "",
index_url = "https://pypi.org/simple/foo",
is_exposed = True,
is_multiple_versions = False,
srcs = [
Expand Down Expand Up @@ -1268,7 +1268,7 @@ def _test_uv_lock_rules_python_pkg_not_skipped(env):
env.expect.that_collection(got).contains_exactly([
struct(
name = "rules_python",
index_url = "",
index_url = "https://pypi.org/simple/rules-python",
is_exposed = True,
is_multiple_versions = False,
srcs = [
Expand Down Expand Up @@ -1301,7 +1301,7 @@ def _test_uv_lock_no_consistency_check(env):
env.expect.that_collection(got).contains_exactly([
struct(
name = "foo",
index_url = "",
index_url = "https://pypi.org/simple/foo",
is_exposed = True,
is_multiple_versions = False,
srcs = [
Expand Down Expand Up @@ -1329,7 +1329,7 @@ def _test_uv_lock_multiple_packages(env):
env.expect.that_collection(got).contains_exactly([
struct(
name = "bar",
index_url = "",
index_url = "https://pypi.org/simple/bar",
is_exposed = True,
is_multiple_versions = False,
srcs = [
Expand All @@ -1347,7 +1347,7 @@ def _test_uv_lock_multiple_packages(env):
),
struct(
name = "foo",
index_url = "",
index_url = "https://pypi.org/simple/foo",
is_exposed = True,
is_multiple_versions = False,
srcs = [
Expand Down Expand Up @@ -1376,7 +1376,7 @@ def _test_uv_lock_with_extra_pip_args(env):
env.expect.that_collection(got).contains_exactly([
struct(
name = "foo",
index_url = "",
index_url = "https://pypi.org/simple/foo",
is_exposed = True,
is_multiple_versions = False,
srcs = [
Expand Down Expand Up @@ -1408,7 +1408,7 @@ def _test_uv_lock_multi_os_with_requirements(env):
env.expect.that_collection(got).contains_exactly([
struct(
name = "foo",
index_url = "",
index_url = "https://pypi.org/simple/foo",
is_exposed = True,
is_multiple_versions = False,
srcs = [
Expand Down Expand Up @@ -1436,7 +1436,7 @@ def _test_uv_lock_extras_optional_deps(env):
env.expect.that_collection(got).contains_exactly([
struct(
name = "foo",
index_url = "",
index_url = "https://pypi.org/simple/foo",
is_exposed = True,
is_multiple_versions = False,
srcs = [
Expand Down Expand Up @@ -1464,7 +1464,7 @@ def _test_uv_lock_extras_dep_edge(env):
env.expect.that_collection(got).contains_exactly([
struct(
name = "bar",
index_url = "",
index_url = "https://pypi.org/simple/bar",
is_exposed = True,
is_multiple_versions = False,
srcs = [
Expand All @@ -1482,7 +1482,7 @@ def _test_uv_lock_extras_dep_edge(env):
),
struct(
name = "foo",
index_url = "",
index_url = "https://pypi.org/simple/foo",
is_exposed = True,
is_multiple_versions = False,
srcs = [
Expand Down Expand Up @@ -1517,7 +1517,7 @@ def _test_uv_lock_wheel_dedup_single_version(env):
env.expect.that_collection(got).contains_exactly([
struct(
name = "foo",
index_url = "",
index_url = "https://pypi.org/simple/foo",
is_exposed = True,
is_multiple_versions = False,
srcs = [
Expand Down Expand Up @@ -1563,7 +1563,7 @@ def _test_uv_lock_wheel_dedup_resolution_markers(env):
env.expect.that_collection(got).contains_exactly([
struct(
name = "foo",
index_url = "",
index_url = "https://pypi.org/simple/foo",
is_exposed = True,
is_multiple_versions = True,
srcs = [
Expand Down Expand Up @@ -1601,7 +1601,7 @@ def _test_uv_lock_requires_dist_extras(env):
env.expect.that_collection(got).contains_exactly([
struct(
name = "foo",
index_url = "",
index_url = "https://pypi.org/simple/foo",
is_exposed = True,
is_multiple_versions = False,
srcs = [
Expand Down