{"id":"d1918e7025425b8e","repo":"pypa/pip","slug":"requested-ireq-has-inconsistent-requires-dist-be","errorCode":null,"errorMessage":"Requested {ireq} has inconsistent Requires-Dist between its PEP 658 .metadata file and the wheel's METADATA: sidecar has {f_val!r}, wheel has {m_val!r}","messagePattern":"Requested (.+?) has inconsistent Requires-Dist between its PEP 658 \\.metadata file and the wheel's METADATA: sidecar has (.+?), wheel has (.+?)","errorType":"exception","errorClass":"SidecarMetadataInconsistent","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/operations/prepare.py","lineNumber":316,"sourceCode":"    if sidecar_name != wheel_name:\n        raise SidecarMetadataInconsistent(req, \"Name\", sidecar_name, wheel_name)\n\n    if sidecar_dist.version != wheel_dist.version:\n        raise SidecarMetadataInconsistent(\n            req,\n            \"Version\",\n            str(sidecar_dist.version),\n            str(wheel_dist.version),\n        )\n\n    # For multi-use fields, only report the symmetric difference to avoid\n    # unnecessarily flagging matching values.\n    sidecar_requires = _canonical_requires(\n        req, sidecar_dist, \"the PEP 658 .metadata file\"\n    )\n    wheel_requires = _canonical_requires(req, wheel_dist, \"the wheel's METADATA\")\n    if sidecar_requires != wheel_requires:\n        raise SidecarMetadataInconsistent(\n            req,\n            \"Requires-Dist\",\n            \", \".join(sorted(sidecar_requires - wheel_requires)),\n            \", \".join(sorted(wheel_requires - sidecar_requires)),\n        )\n\n    if sidecar_dist.requires_python != wheel_dist.requires_python:\n        raise SidecarMetadataInconsistent(\n            req,\n            \"Requires-Python\",\n            str(sidecar_dist.requires_python),\n            str(wheel_dist.requires_python),\n        )\n\n    sidecar_extras = frozenset(sidecar_dist.iter_provided_extras())\n    wheel_extras = frozenset(wheel_dist.iter_provided_extras())\n    if sidecar_extras != wheel_extras:\n        raise SidecarMetadataInconsistent(","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/operations/prepare.py#L298-L334","documentation":"Raised as SidecarMetadataInconsistent for Requires-Dist when the set of canonicalized dependencies in the PEP 658 .metadata sidecar differs from those in the wheel's METADATA. At prepare.py:311-321 both sides are canonicalized via _canonical_requires and compared as frozensets; the message shows the symmetric difference (sidecar-only vs wheel-only) to avoid noise from matching entries.","triggerScenarios":"The dependency list advertised in the sidecar .metadata file doesn't match the wheel's actual dependencies after canonicalization (name casing, extras ordering, specifier differences). Triggered in _check_sidecar_matches_wheel for remote wheels.","commonSituations":"Index serves a stale .metadata after a release that changed dependencies. Mirror desync. A re-published wheel whose deps changed but .metadata wasn't regenerated.","solutions":["Clear caches: pip cache purge and flush any fronting HTTP cache, then retry.","Reinstall against the official index pinned to the exact version: pip install --index-url https://pypi.org/simple/ 'pkg==<ver>'.","Compare the sidecar .metadata and the wheel METADATA Requires-Dist lines directly to confirm the mismatch is on the index side, not local.","Report to the index operator so they regenerate .metadata files."],"exampleFix":"# before: sidecar lists 'numpy>=1', wheel METADATA lists 'numpy>=1.20'\npip install pkg  # -> SidecarMetadataInconsistent Requires-Dist\n\n# after: use official index, exact version, no sidecar reliance\npip install --index-url https://pypi.org/simple/ 'pkg==1.0.0'","handlingStrategy":"validation","validationCode":"from pip._internal.operations.prepare import _canonicalize_requirement\nfrom pip._vendor.packaging.requirements import InvalidRequirement\n\ndef canonical_requires(lines):\n    out = set()\n    for raw in lines:\n        try:\n            out.add(_canonicalize_requirement(raw.strip()))\n        except InvalidRequirement as e:\n            raise ValueError(f\"bad Requires-Dist {raw!r}: {e}\")\n    return frozenset(out)\n\nif canonical_requires(sidecar_requires) != canonical_requires(wheel_requires):\n    print(\"dependency sets differ; do not trust sidecar\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use a trusted index and pin exact versions to avoid stale dependency sidecars.","Regenerate .metadata files whenever dependencies change on a self-hosted index.","Purge caches on first occurrence."],"tags":["metadata","pep658","sidecar","requires-dist","dependencies"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}