@@ -26,12 +26,14 @@ dynamic = ["version"]
2626```
2727
2828This streamlined approach automatically enables version inference when:
29+
2930- ` setuptools-scm[simple] ` is listed in ` build-system.requires `
3031- ` version ` is included in ` project.dynamic `
3132
3233!!! tip "When to use simplified activation"
3334
3435 Use simplified activation when you:
36+
3537 - Want basic SCM version inference with default settings
3638 - Don't need custom version schemes or file writing
3739 - Prefer minimal configuration
@@ -90,6 +92,7 @@ Version files can be created with the ``version_file`` directive.
9092[tool .setuptools_scm ]
9193version_file = " pkg/_version.py"
9294```
95+
9396Where `` pkg `` is the name of your package.
9497
9598Unless the small overhead of introspecting the version at runtime via
@@ -253,6 +256,7 @@ without copying the entire `.git` folder into the container image.
253256RUN --mount=source=.git,target=.git,type=bind \
254257 pip install --no-cache-dir -e .
255258```
259+
256260However, this build step introduces a dependency to the state of your local
257261` .git ` folder the build cache and triggers the long-running pip install process on every build.
258262To optimize build caching, one can use an environment variable to pretend a pseudo
@@ -332,6 +336,7 @@ setuptools-scm's default tag regex supports:
332336- ** Build metadata** : Anything after ` + ` is ignored
333337
334338** Examples of valid tags:**
339+
335340``` bash
336341# Recommended formats (with v prefix)
337342v1.0.0
@@ -390,6 +395,7 @@ The prefixes are automatically added by setuptools-scm and should be included wh
390395specifying node IDs in environment variables like ` SETUPTOOLS_SCM_PRETEND_METADATA ` .
391396
392397** Examples:**
398+
393399``` bash
394400# Git node ID
3954011.0.0.dev5+g1a2b3c4d5
@@ -448,14 +454,16 @@ $ python -m setuptools_scm create-archival-file --full
448454Alternatively, you can create the file manually:
449455
450456** Stable version (recommended):**
451- ``` { .text file=".git_archival.txt"}
457+
458+ ``` { .text title=".git_archival.txt"}
452459node: $Format:%H$
453460node-date: $Format:%cI$
454461describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
455462```
456463
457464** Full version (with branch information - can cause instability):**
458- ``` { .text file=".git_archival.txt"}
465+
466+ ``` { .text title=".git_archival.txt"}
459467# WARNING: Including ref-names can make archive checksums unstable
460468# after commits are added post-release. Use only if describe-name is insufficient.
461469node: $Format:%H$
@@ -475,11 +483,12 @@ tagging style.
475483 post-release. See [this issue][git-archive-issue] for more details.
476484
477485
478- ``` {.text file =".gitattributes"}
486+ ``` {.text title =".gitattributes"}
479487.git_archival.txt export-subst
480488```
481489
482490Finally, commit both files:
491+
483492``` commandline
484493$ git add .git_archival.txt .gitattributes && git commit -m "add git archive support"
485494```
@@ -488,7 +497,7 @@ $ git add .git_archival.txt .gitattributes && git commit -m "add git archive sup
488497
489498If you see warnings like these when building your package:
490499
491- ```
500+ ``` text
492501UserWarning: git archive did not support describe output
493502UserWarning: unprocessed git archival found (no export subst applied)
494503```
@@ -503,7 +512,7 @@ This typically happens when:
503512** For development builds:**
504513Exclude ` .git_archival.txt ` from your package to avoid warnings:
505514
506- ``` { .text file ="MANIFEST.in"}
515+ ``` { .text title ="MANIFEST.in"}
507516# Exclude archival file from development builds
508517exclude .git_archival.txt
509518```
@@ -526,14 +535,15 @@ Many CI systems and package repositories (like GitHub Actions) automatically han
526535#### Integration with package managers
527536
528537** MANIFEST.in exclusions:**
529- ``` { .text file="MANIFEST.in"}
538+
539+ ``` { .text title="MANIFEST.in"}
530540# Exclude development files from packages
531541exclude .git_archival.txt
532542exclude .gitattributes
533543```
534544
535545
536- ``` { .text file =".gitattributes"}
546+ ``` { .text title =".gitattributes"}
537547# Archive configuration
538548.git_archival.txt export-subst
539549.gitignore export-ignore
@@ -542,14 +552,17 @@ exclude .gitattributes
542552#### Troubleshooting
543553
544554** Problem: "unprocessed git archival found" warnings**
555+
545556- ✅ ** Solution** : Add ` exclude .git_archival.txt ` to ` MANIFEST.in ` for development builds
546557- ✅ ** Alternative** : Build from actual git archives for releases
547558
548559** Problem: "git archive did not support describe output" warnings**
560+
549561- ℹ️ ** Information** : This is expected when ` .git_archival.txt ` contains unexpanded templates
550562- ✅ ** Solution** : Same as above - exclude file or build from git archives
551563
552564** Problem: Version detection fails in git archives**
565+
553566- ✅ ** Check** : Is ` .gitattributes ` configured with ` export-subst ` ?
554567- ✅ ** Check** : Are you building from a properly created git archive?
555568- ✅ ** Check** : Does your git hosting provider support archive template expansion?
@@ -561,7 +574,8 @@ exclude .gitattributes
561574!!! note "Version Files"
562575
563576 If you are creating a `_version.py` file, it should not be kept in version control. Add it to `.gitignore`:
564- ```
577+
578+ ```{.ini title=".gitignore"}
565579 # Generated version file
566580 src/mypackage/_version.py
567581 ```
@@ -594,31 +608,36 @@ would be required when not using `setuptools-scm`.
594608** To exclude unwanted files:**
595609
5966101 . ** Use ` MANIFEST.in ` ** to exclude specific files/patterns:
597- ```
598- exclude development.txt
599- recursive-exclude tests *.pyc
600- ```
611+
612+ ``` {.text title="MANIFEST.in"}
613+ exclude development.txt
614+ recursive-exclude tests *.pyc
615+ ```
601616
6026172. **Configure Git archive** (for Git repositories):
603- ``` bash
604- # Add to .gitattributes
605- tests/ export-ignore
606- * .md export-ignore
607- ```
618+
619+ ```{.bash title=".gitattributes"}
620+ # Add to .gitattributes
621+ tests/ export-ignore
622+ *.md export-ignore
623+ ```
608624
6096253. **Use `.hgignore`** or **Mercurial archive configuration** (for Mercurial repositories)
610626
611627#### Troubleshooting
612628
613629**Problem: Unwanted files in my package**
630+
614631- ✅ **Solution**: Add exclusions to `MANIFEST.in`
615632- ✅ **Alternative**: Use Git/Mercurial archive configuration
616633
617634**Problem: Missing files in package**
635+
618636- ✅ **Check**: Are the files tracked in your SCM?
619637- ✅ **Solution**: `git add` missing files or override with `MANIFEST.in`
620638
621639**Problem: File finder not working**
640+
622641- ✅ **Check**: Is setuptools-scm installed in your build environment?
623642- ✅ **Check**: Are you in a valid SCM repository?
624643
0 commit comments