{"id":"acff0d8a94c654cf","repo":"pypa/pip","slug":"requested-ireq-has-inconsistent-name-between-its","errorCode":null,"errorMessage":"Requested {ireq} has inconsistent Name 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 Name 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":299,"sourceCode":") -> None:\n    \"\"\"Check that a .metadata-based distribution matches the wheel's METADATA.\n\n    Compare ``Name``, ``Version``, ``Requires-Dist``, ``Requires-Python``\n    and ``Provides-Extra`` between the two and abort the install on any\n    mismatch as PEP 658 requires the metadata files \"MUST be identical\".\n\n    While the PEP doesn't mandate that consumers enforce the identical\n    requirement, it's good nonetheless to check to prevent confusing\n    behaviour when an index misbehaves.\n\n    Also note for name and version, pip usually rejects wheels if they're\n    inconsistent already. Checking them again here is purely defensive.\n    \"\"\"\n\n    sidecar_name = canonicalize_name(sidecar_dist.raw_name)\n    wheel_name = canonicalize_name(wheel_dist.raw_name)\n    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,","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/operations/prepare.py#L281-L317","documentation":"Raised as SidecarMetadataInconsistent for the Name field when the canonicalized project name in a PEP 658 .metadata sidecar differs from the name in the downloaded wheel's METADATA. PEP 658 requires the sidecar to be identical to the wheel METADATA; this check at prepare.py:296-299 enforces it to prevent a misbehaving index from causing confusing dependency resolution.","triggerScenarios":"An index serves a .metadata file whose Name field canonicalizes differently from the wheel's actual METADATA Name. Occurs during _check_sidecar_matches_wheel after the wheel is fully downloaded and only for remote wheels where a metadata_link() was used.","commonSituations":"A misconfigured or compromised package index, a caching proxy that served a stale/mismatched .metadata file, or a mirror that is mid-sync. Very rare on PyPI proper.","solutions":["Clear the local download cache and pip cache: pip cache purge, then retry.","Switch to the canonical index: pip install --index-url https://pypi.org/simple/ <pkg>.","Pin the exact wheel by hash/URL so pip does not rely on the sidecar metadata.","If you operate the index, ensure .metadata files are regenerated whenever the wheel is updated."],"exampleFix":"# before: index serves mismatched sidecar\npip install pkg  # -> SidecarMetadataInconsistent Name\n\n# after: bypass sidecar via direct wheel URL with hash\npip install https://files.pythonhosted.org/.../pkg-1.0-py3-none-any.whl --require-hashes","handlingStrategy":"fallback","validationCode":"from pip._vendor.packaging.utils import canonicalize_name\n# compare sidecar name vs wheel METADATA name before relying on resolution\nif canonicalize_name(sidecar_name) != canonicalize_name(wheel_name):\n    logger.warning(\"sidecar/wheel name mismatch; falling back to direct wheel\")","typeGuard":"from pip._vendor.packaging.utils import canonicalize_name\ndef names_match(a: str, b: str) -> bool:\n    return canonicalize_name(a) == canonicalize_name(b)","tryCatchPattern":null,"preventionTips":["Pin exact versions from a trusted index to avoid relying on sidecar metadata.","Purge pip and HTTP caches when seeing consistency errors.","If operating an index, regenerate .metadata files on every wheel upload."],"tags":["metadata","pep658","sidecar","packaging","install"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}