{"id":"e7523a644702c49d","repo":"pypa/pip","slug":"cannot-determine-wheel-filename","errorCode":null,"errorMessage":"Cannot determine wheel filename","messagePattern":"Cannot determine wheel filename","errorType":"validation","errorClass":"PylockValidationError","httpStatus":null,"severity":"error","filePath":"src/pip/_vendor/packaging/pylock.py","lineNumber":515,"sourceCode":"    @classmethod\n    def _from_dict(cls, d: Mapping[str, Any]) -> Self:\n        package_wheel = cls(\n            name=_get(d, str, \"name\"),\n            upload_time=_get(d, datetime, \"upload-time\"),\n            url=_get(d, str, \"url\"),\n            path=_get(d, str, \"path\"),\n            size=_get(d, int, \"size\"),\n            hashes=_get_required_as(d, Mapping, _validate_hashes, \"hashes\"),  # type: ignore[type-abstract]\n        )\n        _validate_path_url(package_wheel.path, package_wheel.url)\n        return package_wheel\n\n    @property\n    def filename(self) -> str:\n        \"\"\"Get the filename of the wheel.\"\"\"\n        filename = self.name or _path_name(self.path) or _url_name(self.url)\n        if not filename:\n            raise PylockValidationError(\"Cannot determine wheel filename\")\n        return filename\n\n\n@dataclass(frozen=True, init=False)\nclass Package:\n    name: NormalizedName\n    version: Version | None = None\n    marker: Marker | None = None\n    requires_python: SpecifierSet | None = None\n    dependencies: Sequence[Mapping[str, Any]] | None = None\n    vcs: PackageVcs | None = None\n    directory: PackageDirectory | None = None\n    archive: PackageArchive | None = None\n    index: str | None = None\n    sdist: PackageSdist | None = None\n    wheels: Sequence[PackageWheel] | None = None\n    attestation_identities: Sequence[Mapping[str, Any]] | None = None\n    tool: Mapping[str, Any] | None = None","sourceCodeStart":497,"sourceCodeEnd":533,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_vendor/packaging/pylock.py#L497-L533","documentation":"Raised as PylockValidationError by PackageWheel.filename (a computed property) in packaging.pylock when none of name, path, or url is set on a wheel entry, so the wheel filename cannot be derived. The filename is required by parse_wheel_filename for the wheel-name/version consistency checks in Package._from_dict.","triggerScenarios":"A [[packages.wheels]] table with neither name, path, nor url; or a PackageWheel(...) constructed in code without any locator. Accessing .filename (often indirectly via the wheel validation loop at line ~597) triggers it.","commonSituations":"Lockfile with a wheel entry missing its locator fields; resolver that wrote the wheel hash but not the filename/URL; hand-editing that deleted the URL.","solutions":["Provide name (e.g. 'pkg-1.0-py3-none-any.whl'), path, or url on each wheel entry.","Regenerate the lockfile so every wheel records its filename or URL.","Validate wheels before adding them to the package.","Catch the error and report which wheel index is malformed (context)."],"exampleFix":"# before\n[[packages.wheels]]\nhashes = { sha256 = \\\"...\\\" }\n# after\n[[packages.wheels]]\nname = \\\"pkg-1.0-py3-none-any.whl\\\"\nhashes = { sha256 = \\\"...\\\" }","handlingStrategy":"validation","validationCode":"def wheel_has_filename(w: dict) -> bool:\n    return bool(w.get('name') or w.get('path') or w.get('url'))","typeGuard":"def is_named_wheel(d) -> bool:\n    return bool(d.get('name') or d.get('path') or d.get('url'))","tryCatchPattern":"try:\n    _ = wheel.filename\nexcept PylockValidationError as e:\n    if 'Cannot determine wheel filename' in str(e):\n        w['name'] = f'{pkg.name}-{pkg.version}-py3-none-any.whl'","preventionTips":["Provide name (full wheel filename) or path/url on each wheel.","Use a resolver to populate wheel filenames.","Validate each wheel entry has a locator.","Catch the error and report the wheel index (context)."],"tags":["pylock","pep771","wheel","validation"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}