Improve the error message when invalid (git) tag is provided
If a git tag is provided with an incorrect format, pip
fails with a rather messy message:
$ pip install .[test]
Processing /builds/2mk6rsew/0/sgilles/cppyy_kernel
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'error'
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [30 lines of output]
/tmp/pip-build-env-w8b0g0ci/overlay/lib/python3.12/site-packages/setuptools_scm/git.py:167: UserWarning: "/builds/2mk6rsew/0/sgilles/cppyy_kernel" is shallow and may cause errors
warnings.warn(f'"{wd.path}" is shallow and may cause errors')
/tmp/pip-build-env-w8b0g0ci/overlay/lib/python3.12/site-packages/setuptools_scm/version.py:102: UserWarning: tag 'test_52.1' no version found
warnings.warn(f"tag {tag!r} no version found")
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 152, in prepare_metadata_for_build_wheel
whl_basename = backend.build_wheel(metadata_directory, config_settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-w8b0g0ci/overlay/lib/python3.12/site-packages/hatchling/build.py", line 58, in build_wheel
return os.path.basename(next(builder.build(directory=wheel_directory, versions=['standard'])))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-w8b0g0ci/overlay/lib/python3.12/site-packages/hatchling/builders/plugin/interface.py", line 90, in build
self.metadata.validate_fields()
File "/tmp/pip-build-env-w8b0g0ci/overlay/lib/python3.12/site-packages/hatchling/metadata/core.py", line 265, in validate_fields
_ = self.version
^^^^^^^^^^^^
File "/tmp/pip-build-env-w8b0g0ci/overlay/lib/python3.12/site-packages/hatchling/metadata/core.py", line 149, in version
self._version = self._get_version()
^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-w8b0g0ci/overlay/lib/python3.12/site-packages/hatchling/metadata/core.py", line 248, in _get_version
version = self.hatch.version.cached
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-w8b0g0ci/overlay/lib/python3.12/site-packages/hatchling/metadata/core.py", line 1456, in cached
raise type(e)(message) from None
AssertionError: Error getting the version from source `vcs`:
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
[notice] A new release of pip is available: 24.3.1 -> 25.0.1
[notice] To update, run: pip install --upgrade pip
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
It would be better to indicate clearly what goes wrong!