{"id":"e6577cfafe9550eb","repo":"python-poetry/poetry","slug":"unable-to-determine-package-info-from-path-file","errorCode":null,"errorMessage":"Unable to determine package info from path: {file_path}","messagePattern":"Unable to determine package info from path: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/poetry/packages/direct_origin.py","lineNumber":72,"sourceCode":"\n    return package\n\n\nclass DirectOrigin:\n    def __init__(self, artifact_cache: ArtifactCache) -> None:\n        self._artifact_cache = artifact_cache\n        config = Config.create()\n        self._max_retries = config.get(\"requests.max-retries\", 0)\n        self._authenticator = get_default_authenticator()\n\n    @classmethod\n    def get_package_from_file(cls, file_path: Path) -> Package:\n        try:\n            package = PackageInfo.from_path(path=file_path).to_package(\n                root_dir=file_path\n            )\n        except PackageInfoError:\n            raise RuntimeError(\n                f\"Unable to determine package info from path: {file_path}\"\n            )\n\n        package.files = [\n            {\n                \"file\": file_path.name,\n                \"hash\": \"sha256:\" + get_file_hash(file_path),\n                \"size\": file_path.stat().st_size,\n            }\n        ]\n\n        return package\n\n    @classmethod\n    def get_package_from_directory(cls, directory: Path) -> Package:\n        return PackageInfo.from_directory(path=directory).to_package(root_dir=directory)\n\n    def _download_file(self, url: str, dest: Path) -> None:","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/packages/direct_origin.py#L54-L90","documentation":"Raised by DirectOrigin.get_package_from_file at src/poetry/packages/direct_origin.py:66-74 when PackageInfo.from_path(path=file_path) raises PackageInfoError (cannot parse the file as a wheel/sdist). The original error is swallowed and re-raised as RuntimeError pointing at the path. Used for file:// and URL-based direct dependency resolution.","triggerScenarios":"Passing a path that is not a valid Python archive — e.g. a zip that isn't a wheel, a tarball without PKG-INFO, a .py file, or a non-existent/garbled file — to get_package_from_file. Reached via `poetry add ./file` or direct-origin dependency resolution.","commonSituations":"Pointing Poetry at a downloaded archive that is incomplete or not a real sdist/wheel (e.g. a GitHub 'Source code' zip which lacks proper metadata), a corrupt download, or a wrong file extension.","solutions":["Confirm the file is a well-formed wheel (.whl) or sdist (.tar.gz with PKG-INFO).","Re-download or rebuild the artifact: `python -m build` then point at dist/*.{whl,tar.gz}.","Prefer adding a directory (poetry add ./pkg_dir/) over a raw archive when you control the source."],"exampleFix":"# before\n$ poetry add ./mypkg.zip     # github source zip, not a real sdist\nRuntimeError: Unable to determine package info from path: /path/mypkg.zip\n\n# after\n$ python -m build            # produces dist/mypkg-1.0-py3-none-any.whl\n$ poetry add ./dist/mypkg-1.0-py3-none-any.whl","handlingStrategy":"try-catch","validationCode":"import pkginfo\n\ndef is_valid_archive(path) -> bool:\n    try:\n        info = pkginfo.get_metadata(str(path))\n        return info is not None and bool(getattr(info, 'name', None))\n    except Exception:\n        return False","typeGuard":null,"tryCatchPattern":"from poetry.packages.direct_origin import DirectOrigin\n\ntry:\n    pkg = DirectOrigin.get_package_from_file(Path(path))\nexcept RuntimeError as e:\n    if 'Unable to determine package info' in str(e):\n        raise SystemExit(f'{path} is not a valid sdist/wheel; rebuild or re-download.') from e\n    raise","preventionTips":["Use wheels or properly built sdists as file dependencies.","Avoid GitHub 'Source code (zip)' — it lacks PKG-INFO; prefer release artifacts or a real sdist."],"tags":["direct-origin","package-info","file-dependency","archive","runtime-error"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}