{"record":{"id":"d5903571b7065fb6","repo":"pypa/pip","slug":"version-in-wheel-filename-r-is-not-consistent-wi","errorCode":null,"errorMessage":"Version in {wheel.filename!r} is not consistent with package version {str(package.version)!r}","messagePattern":"Version in (.+?) is not consistent with package version (.+?)","errorType":"validation","errorClass":"PylockValidationError","httpStatus":null,"severity":"error","filePath":"src/pip/_vendor/packaging/pylock.py","lineNumber":628,"sourceCode":"                \"Exactly one of vcs, directory, archive must be set \"\n                \"if sdist and wheels are not set\"\n            )\n        for i, wheel in enumerate(package.wheels or []):\n            try:\n                (name, version, _, _) = parse_wheel_filename(wheel.filename)\n            except Exception as e:\n                raise PylockValidationError(\n                    f\"Invalid wheel filename {wheel.filename!r}\",\n                    context=f\"wheels[{i}]\",\n                ) from e\n            if name != package.name:\n                raise PylockValidationError(\n                    f\"Name in {wheel.filename!r} is not consistent with \"\n                    f\"package name {package.name!r}\",\n                    context=f\"wheels[{i}]\",\n                )\n            if package.version and version != package.version:\n                raise PylockValidationError(\n                    f\"Version in {wheel.filename!r} is not consistent with \"\n                    f\"package version {str(package.version)!r}\",\n                    context=f\"wheels[{i}]\",\n                )\n        if package.sdist:\n            try:\n                name, version = parse_sdist_filename(package.sdist.filename)\n            except Exception as e:\n                raise PylockValidationError(\n                    f\"Invalid sdist filename {package.sdist.filename!r}\",\n                    context=\"sdist\",\n                ) from e\n            if name != package.name:\n                raise PylockValidationError(\n                    f\"Name in {package.sdist.filename!r} is not consistent with \"\n                    f\"package name {package.name!r}\",\n                    context=\"sdist\",\n                )","sourceCodeStart":610,"sourceCodeEnd":646,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_vendor/packaging/pylock.py#L610-L646","documentation":"PylockValidationError: the version parsed from a wheel filename disagrees with the package's declared 'version' field. This only fires when package.version is non-empty; PEP 751 requires the filename version to equal the package version so an installer never installs a file claiming a different release.","triggerScenarios":"Package validation iterates wheels; for each, parse_wheel_filename yields a version that is compared (after PEP 440 normalization) to package.version. Fires when e.g. version=\"2.31.0\" but a wheel is named 'requests-2.30.0-py3-none-any.whl', or a wheel for an older build was left in the entry.","commonSituations":"Partial lock update where the package version was bumped but the old wheel filenames were not refreshed; a stale wheel cached and re-recorded by a buggy locker; local-version or post-version spelling differences that normalize differently.","solutions":["Check the version segment of every wheel filename (between the first and second dash) against the package's version field.","Update the wheel filenames (or remove stale ones) so each matches the declared package version.","Regenerate the lock so wheel filenames and the package version stay in sync.","Re-run Pylock.validate()."],"exampleFix":"# before\n[[packages]]\nname = \"requests\"\nversion = \"2.31.0\"\n  [[packages.wheels]]\n  filename = \"requests-2.30.0-py3-none-any.whl\"\n\n# after\n[[packages]]\nname = \"requests\"\nversion = \"2.31.0\"\n  [[packages.wheels]]\n  filename = \"requests-2.31.0-py3-none-any.whl\"","handlingStrategy":"validation","validationCode":"from packaging.utils import parse_wheel_filename\nfrom packaging.version import Version\n\ndef wheel_version_consistent(filename: str, version: str) -> bool:\n    try:\n        _, ver, *_ = parse_wheel_filename(filename)\n    except Exception:\n        return False\n    return not version or Version(str(ver)) == Version(version)\n\nfor p in toml_dict.get('packages', []):\n    v = p.get('version')\n    for w in p.get('wheels', []) or []:\n        assert wheel_version_consistent(w['filename'], v), (w['filename'], v)","typeGuard":"null","tryCatchPattern":"try:\n    Pylock.from_dict(toml_dict)\nexcept PylockValidationError as e:\n    # e.context names wheels[i]; align its version segment with package.version\n    report(e.context, e.message)","preventionTips":["When bumping a package version, refresh every wheel filename in that package block in the same edit.","Discard stale wheels from the entry; do not carry old releases forward.","Let the locker own filename/version coherence; avoid hand-edits."],"tags":["pylock","packaging","validation","version","wheel"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}