readthedocs.org: Stable build does not make git tag available during build

Details

Expected Result

The “stable” build of my project is accurately grabbing the commit SHA associated with the most recent tag. I expect that during the build process there is enough git context for git commands to determine the name of the tag that is currently checked out. This is used heavily by dynamic version software (ex. setuptools-scm, versioneer, etc).

Actual Result

During the git checkout process of getting the repository it does not actually have any of the tag information. So when my python package calls into setuptools-scm to determine the version number it uses a fallback (nonsense) version number.

CC @gerritholl who identified the issue in our documentation.

If I run the same git commands as in the linked build above locally and then run setuptools-scm manually I get:

$ python -m setuptools_scm
/home/davidh/miniconda3/envs/satpy_py311_2/lib/python3.11/site-packages/setuptools_scm/git.py:135: UserWarning: "/tmp/rtd_test" is shallow and may cause errors
  warnings.warn(f'"{wd.path}" is shallow and may cause errors')
0.1.dev10921+g18288df

If I instead checkout all commits (just as a test), then checkout the specific SHA, then run it I get:

$ python -m setuptools_scm
/home/davidh/miniconda3/envs/satpy_py311_2/lib/python3.11/site-packages/setuptools_scm/git.py:135: UserWarning: "/tmp/rtd_test" is shallow and may cause errors
  warnings.warn(f'"{wd.path}" is shallow and may cause errors')
0.43.0

Am I maybe breaking something with my .readthedocs.yaml?

About this issue

  • Original URL
  • State: open
  • Created 10 months ago
  • Comments: 17 (10 by maintainers)

Most upvoted comments

We are now facing the same issue for this doc.

As already noticed above, the git commands have changed and now the tags are absent which causes tools like setuptools-scm to no longer be able to determine the version.

It seems that the following git command

 git fetch origin --force --prune --prune-tags --depth 50 18288df8dc943fc07322f47c435c08113abb0b8a 

could be replaced by

 git fetch origin --force --prune --tags --depth 50 18288df8dc943fc07322f47c435c08113abb0b8a 

and the tags are back.