actions/setup-python cache fails: pyproject.toml has no version
By Daniel Zoghalchali·Latchkey
setup-python can read the version from python-version-file. A pyproject.toml without a Python version (or with the version under a tool table the action does not read) leaves the version unresolved, breaking setup and cache keying.
What this error means
The setup-python step fails to resolve a version from pyproject.toml or the cache key cannot be computed.
github-actions
Error: Could not determine the Python version from the file: pyproject.toml
##[error]Version not found in pyproject.toml
Common causes
No Python version in pyproject
The file lacks a requires-python / tool version the action reads.
Wrong version-file target
python-version-file points at a file without a parseable version.
How to fix it
Provide python-version or a valid version file
Set python-version directly, or add requires-python to pyproject.toml.
Or point python-version-file at a .python-version file.