python-poetry/poetry · error · RuntimeError
Unable to determine package info from path: {file_path}
Error message
Unable to determine package info from path: {file_path} What it means
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.
Source
Thrown at src/poetry/packages/direct_origin.py:72
return package
class DirectOrigin:
def __init__(self, artifact_cache: ArtifactCache) -> None:
self._artifact_cache = artifact_cache
config = Config.create()
self._max_retries = config.get("requests.max-retries", 0)
self._authenticator = get_default_authenticator()
@classmethod
def get_package_from_file(cls, file_path: Path) -> Package:
try:
package = PackageInfo.from_path(path=file_path).to_package(
root_dir=file_path
)
except PackageInfoError:
raise RuntimeError(
f"Unable to determine package info from path: {file_path}"
)
package.files = [
{
"file": file_path.name,
"hash": "sha256:" + get_file_hash(file_path),
"size": file_path.stat().st_size,
}
]
return package
@classmethod
def get_package_from_directory(cls, directory: Path) -> Package:
return PackageInfo.from_directory(path=directory).to_package(root_dir=directory)
def _download_file(self, url: str, dest: Path) -> None:View on GitHub (pinned to 92b74dcfe3)
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.
Example fix
# before $ poetry add ./mypkg.zip # github source zip, not a real sdist RuntimeError: Unable to determine package info from path: /path/mypkg.zip # after $ python -m build # produces dist/mypkg-1.0-py3-none-any.whl $ poetry add ./dist/mypkg-1.0-py3-none-any.whl
Defensive patterns
Strategy: try-catch
Validate before calling
import pkginfo
def is_valid_archive(path) -> bool:
try:
info = pkginfo.get_metadata(str(path))
return info is not None and bool(getattr(info, 'name', None))
except Exception:
return False Try / catch
from poetry.packages.direct_origin import DirectOrigin
try:
pkg = DirectOrigin.get_package_from_file(Path(path))
except RuntimeError as e:
if 'Unable to determine package info' in str(e):
raise SystemExit(f'{path} is not a valid sdist/wheel; rebuild or re-download.') from e
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unable to create package with no name for {root_dir}
- Unable to retrieve the package version for {name}
- Unsupported VCS dependency {vcs}
- Archive ({file}) does not exist
- Unknown distribution format {exts}
AI-assisted analysis of python-poetry/poetry@92b74dcfe3 (2026-08-04).
Data as JSON: /data/errors/e6577cfafe9550eb.json.
Report an issue: GitHub.