{"record":{"id":"d3ec188483da6b1b","repo":"pypa/pip","slug":"unexpected-file-in-wheel-path-record-path-r","errorCode":null,"errorMessage":"Unexpected file in {wheel_path}: {record_path!r}. .data directory contents should be named like: '<scheme key>/<path>'.","messagePattern":"Unexpected file in (.+?): (.+?)\\. \\.data directory contents should be named like: '<scheme key>/<path>'\\.","errorType":"exception","errorClass":"InstallationError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/operations/install/wheel.py","lineNumber":530,"sourceCode":"            return ZipBackedFile(record_path, dest_path, zip_file)\n\n        return make_root_scheme_file\n\n    def data_scheme_file_maker(\n        zip_file: ZipFile, scheme: Scheme\n    ) -> Callable[[RecordPath], File]:\n        scheme_paths = {key: getattr(scheme, key) for key in SCHEME_KEYS}\n\n        def make_data_scheme_file(record_path: RecordPath) -> File:\n            normed_path = os.path.normpath(record_path)\n            try:\n                _, scheme_key, dest_subpath = normed_path.split(os.path.sep, 2)\n            except ValueError:\n                message = (\n                    f\"Unexpected file in {wheel_path}: {record_path!r}. .data directory\"\n                    \" contents should be named like: '<scheme key>/<path>'.\"\n                )\n                raise InstallationError(message)\n\n            try:\n                scheme_path = scheme_paths[scheme_key]\n            except KeyError:\n                valid_scheme_keys = \", \".join(sorted(scheme_paths))\n                message = (\n                    f\"Unknown scheme key used in {wheel_path}: {scheme_key} \"\n                    f\"(for file {record_path!r}). .data directory contents \"\n                    f\"should be in subdirectories named with a valid scheme \"\n                    f\"key ({valid_scheme_keys})\"\n                )\n                raise InstallationError(message)\n\n            dest_path = os.path.join(scheme_path, dest_subpath)\n            assert_no_path_traversal(scheme_path, dest_path)\n            return ZipBackedFile(record_path, dest_path, zip_file)\n\n        return make_data_scheme_file","sourceCodeStart":512,"sourceCodeEnd":548,"githubUrl":"https://github.com/pypa/pip/blob/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/operations/install/wheel.py#L512-L548","documentation":"Raised as InstallationError by make_data_scheme_file when a file inside the wheel's .data directory cannot be split into '<scheme_key>/<path>' (normed_path.split(os.path.sep, 2) yields fewer than three parts). The .data directory must contain files organised under a scheme-key subdirectory, not flat files.","triggerScenarios":"The wheel contains a path like 'pkg-1.0.data/flatfile' (a file directly under the .data dir) instead of 'pkg-1.0.data/scripts/flatfile', so the scheme key cannot be extracted.","commonSituations":"Malformed wheel produced by a non-standard or buggy build backend; manually constructed wheels with a flat .data layout; truncated/corrupt archive.","solutions":["Rebuild the wheel with a standard build backend that produces the correct '<key>/<path>' .data layout.","Inspect the wheel's namelist to confirm .data entries are under a scheme-key subdir.","Use a different/more recent version of the package whose wheel is well-formed."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"def data_path_well_formed(record_path: str) -> bool:\n    # .data entries must be '<anything>.data/<key>/<subpath>'\n    parts = record_path.split(\"/\")\n    return len(parts) >= 3 and parts[0].endswith(\".data\")\n\n# assert data_path_well_formed(\"pkg-1.0.data/scripts/x\")\n# assert not data_path_well_formed(\"pkg-1.0.data/flatfile\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build wheels with standard backends that produce correct .data layouts.","Inspect wheel namelists for flat .data files before publishing.","Reject malformed wheels from third parties."],"tags":["packaging","wheel","scheme","data-directory"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}