{"record":{"id":"218fc8919057b4dd","repo":"pypa/pip","slug":"requested-ireq-has-inconsistent-requires-python","errorCode":null,"errorMessage":"Requested {ireq} has inconsistent Requires-Python 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-Python 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":324,"sourceCode":"            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(\n            req,\n            \"Provides-Extra\",\n            \", \".join(sorted(sidecar_extras - wheel_extras)),\n            \", \".join(sorted(wheel_extras - sidecar_extras)),\n        )\n\n\nclass RequirementPreparer:","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/operations/prepare.py#L306-L342","documentation":"Raised by _check_sidecar_matches_wheel (prepare.py:323) as SidecarMetadataInconsistent for Requires-Python. If the sidecar's Requires-Python field differs from the wheel's, pip aborts because the resolver may have chosen a wheel incompatible with the running interpreter based on stale sidecar data.","triggerScenarios":"PEP 658 sidecar Requires-Python string differs from the wheel's METADATA Requires-Python string (e.g. '>=3.8' vs '>=3.9').","commonSituations":"A mirror updated a wheel after a Python-version requirement bump without refreshing the sidecar; inconsistent repackaging of a wheel by a proxy/cache.","solutions":["Use the official PyPI or a verified mirror.","Purge local pip cache and retry.","Pin a version known to be consistent for your interpreter.","Report the inconsistent metadata to the index operator."],"exampleFix":"# before\npip install pkg\n# after\npip install --no-cache-dir -i https://pypi.org/simple/ 'pkg==3.1.2'","handlingStrategy":"validation","validationCode":"from email.parser import Parser\nimport zipfile, io, requests\n\ndef sidecar_requires_python_matches(wheel_url: str, sidecar_url: str) -> bool:\n    wb = requests.get(wheel_url).content\n    zf = zipfile.ZipFile(io.BytesIO(wb))\n    m_w = Parser().parsestr(zf.read(next(n for n in zf.namelist() if n.endswith('.dist-info/METADATA'))).decode())\n    m_s = Parser().parsestr(requests.get(sidecar_url).text)\n    return (m_w.get('Requires-Python') or '') == (m_s.get('Requires-Python') or '')","typeGuard":"def requires_python_match(sidecar_rp: str | None, wheel_rp: str | None) -> bool:\n    return (sidecar_rp or '') == (wheel_rp or '')","tryCatchPattern":"from subprocess import run\nrun([\"pip\", \"install\", \"--no-cache-dir\", \"-i\", \"https://pypi.org/simple/\", pkg], check=True)","preventionTips":["Use trusted indexes for reproducible installs.","Purge pip cache when encountering sidecar inconsistencies.","Ensure your interpreter version is supported by the pinned package version."],"tags":["pep658","metadata","sidecar","requires-python","index","pip"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}