Skip to content

Commit 8d58d62

Browse files
fix #790: document rtd workaround to ensure failure on too shallow scm
1 parent cc3a61e commit 8d58d62

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
- fix #279: expand errors when scm can be found upwards and relative_to wasnt used
3535
- fix #577: introduce explicit scmversion node and short node
3636
- fix #1100: add workaround for readthedocs worktress to the docs
37+
- fix #790: document shallow fail for rtd
3738

3839
## v8.3.1
3940

docs/integrations.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,28 @@ build:
2323
2424
This ensures a clean Git working directory before setuptools-scm detects the version, preventing unwanted local version components.
2525
26-
Reference: [ReadTheDocs Build Customization - Avoid having a dirty Git index](https://docs.readthedocs.com/platform/stable/build-customization.html#avoid-having-a-dirty-git-index)
26+
27+
28+
Reference: [ReadTheDocs Build Customization - Avoid having a dirty Git index](https://docs.readthedocs.com/platform/stable/build-customization.html#avoid-having-a-dirty-git-index)
29+
30+
31+
### Enforce fail on shallow repositories
32+
33+
ReadTheDocs may sometimes use shallow Git clones that lack the full history needed for proper version detection. You can use setuptools-scm's environment variable override system to enforce `fail_on_shallow` when building on ReadTheDocs:
34+
35+
```yaml title=".readthedocs.yaml"
36+
version: 2
37+
build:
38+
os: "ubuntu-22.04"
39+
tools:
40+
python: "3.10"
41+
jobs:
42+
post_checkout:
43+
# Avoid setuptools-scm dirty Git index issues
44+
- git reset --hard HEAD
45+
- git clean -fdx
46+
# Enforce fail_on_shallow for setuptools-scm
47+
- export SETUPTOOLS_SCM_OVERRIDES_FOR_${READTHEDOCS_PROJECT//-/_}='{scm.git.pre_parse="fail_on_shallow"}'
48+
```
49+
50+
This configuration uses the `SETUPTOOLS_SCM_OVERRIDES_FOR_${NORMALIZED_DIST_NAME}` environment variable to override the `scm.git.pre_parse` setting specifically for your project when building on ReadTheDocs, forcing setuptools-scm to fail with a clear error if the repository is shallow.

0 commit comments

Comments
 (0)