Skip to content

Commit 664a55a

Browse files
Merge pull request #1165 from RonnyPfannschmidt/fix-docs-issues
documentation fixes - next round
2 parents e3fd4ff + fc9f708 commit 664a55a

File tree

17 files changed

+239
-61
lines changed

17 files changed

+239
-61
lines changed

.github/workflows/python-tests.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ jobs:
5151
with:
5252
python-version: ${{ matrix.python_version }}
5353
architecture: x64
54+
- name: Install the latest version of uv
55+
uses: astral-sh/setup-uv@v6
5456
- name: Setup MSYS2
5557
uses: msys2/setup-msys2@v2
5658
if: matrix.python_version == 'msys2'
@@ -81,20 +83,20 @@ jobs:
8183
echo "C:\Program Files (x86)\gnupg\bin" >> $env:GITHUB_PATH
8284
git config --system gpg.program "C:\Program Files (x86)\gnupg\bin\gpg.exe"
8385
if: runner.os == 'Windows'
84-
- run: pip install -U 'setuptools>=61'
86+
- run: uv sync --group test --group docs --extra rich
8587
- uses: actions/download-artifact@v4
8688
with:
8789
name: Packages
8890
path: dist
8991
- shell: bash
90-
run: pip install "$(echo -n dist/*whl)[toml,test]"
92+
run: uv pip install "$(echo -n dist/*whl)"
9193
- run: |
9294
$(hg debuginstall --template "{pythonexe}") -m pip install hg-git --user
9395
if: matrix.os == 'ubuntu-latest'
9496
# this hopefully helps with os caches, hg init sometimes gets 20s timeouts
9597
- run: hg version
96-
- run: pytest
97-
timeout-minutes: 15
98+
- run: uv run pytest
99+
timeout-minutes: 25
98100

99101
dist_upload:
100102

.readthedocs.yaml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
version: 2
2-
build:
3-
os: ubuntu-22.04
4-
tools:
5-
python: "3.11"
62

73
mkdocs:
84
configuration: mkdocs.yml
95

10-
# Optionally declare the Python requirements required to build your docs
11-
python:
12-
install:
13-
- method: pip
14-
path: .
15-
extra_requirements:
16-
- docs
6+
7+
build:
8+
os: ubuntu-24.04
9+
tools:
10+
python: "3.13"
11+
jobs:
12+
install:
13+
- pip install -U pip # Official recommended way
14+
- pip install .
15+
- pip install --group docs

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
- reduce complexity of HgWorkdir.get_meta method by extracting focused helper methods
1919
- fix #1150: enable setuptools-scm when we are a build requirement
2020
- feature #1154: add the commit id the the default version file template
21-
21+
- drop scriv
2222

2323
### Fixed
2424

@@ -36,6 +36,9 @@
3636
- fix #1100: add workaround for readthedocs worktress to the docs
3737
- fix #790: document shallow fail for rtd
3838
- fix #474: expand version not found error message to provide clearer guidance about SETUPTOOLS_SCM_PRETEND_VERSION_FOR_* environment variables
39+
- fix #324: document/recommend the v tag prefix
40+
- fix #501: add py.typed
41+
- fix #804: git - use fallback version instead of 0.0 when no version is found at all
3942

4043
## v8.3.1
4144

docs/config.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ Callables or other Python objects have to be passed in `setup.py` (via the `use_
6767
named `version`, that captures the actual version information.
6868

6969
Defaults to the value of [setuptools_scm._config.DEFAULT_TAG_REGEX][]
70+
which supports tags with optional "v" prefix (recommended), project prefixes,
71+
and various version formats.
72+
73+
!!! tip
74+
75+
The default regex supports common tag formats like `v1.0.0`, `myproject-v1.0.0`,
76+
and `1.0.0`. For best practices on tag naming, see
77+
[Version Tag Formats](usage.md#version-tag-formats).
7078

7179
`parentdir_prefix_version: str|None = None`
7280
: If the normal methods for detecting the version (SCM version,

docs/extending.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ representing the version.
5858
and custom `.devN` versions will trigger an error.
5959

6060
**Examples:**
61-
- Tag `1.0.0` → version `1.0.1.dev0` (if dirty or distance > 0)
62-
- Tag `1.0.0` → version `1.0.0` (if exact match)
61+
- Tag `v1.0.0` → version `1.0.1.dev0` (if dirty or distance > 0)
62+
- Tag `v1.0.0` → version `1.0.0` (if exact match)
6363

6464
`calver-by-date`
6565
: Calendar versioning scheme that generates versions based on dates.
@@ -69,25 +69,25 @@ representing the version.
6969
for release branches.
7070

7171
**Examples:**
72-
- Tag `23.01.15.0` on same day → version `23.01.15.1.devN`
73-
- Tag `23.01.15.0` on different day (e.g., 2023-01-16) → version `23.01.16.0.devN`
74-
- Tag `2023.01.15.0` → uses 4-digit year format for new versions
72+
- Tag `v23.01.15.0` on same day → version `23.01.15.1.devN`
73+
- Tag `v23.01.15.0` on different day (e.g., 2023-01-16) → version `23.01.16.0.devN`
74+
- Tag `v2023.01.15.0` → uses 4-digit year format for new versions
7575

7676
`no-guess-dev`
7777
: Does no next version guessing, just adds `.post1.devN`.
7878
This is the recommended replacement for the deprecated `post-release` scheme.
7979

8080
**Examples:**
81-
- Tag `1.0.0` → version `1.0.0.post1.devN` (if distance > 0)
82-
- Tag `1.0.0` → version `1.0.0` (if exact match)
81+
- Tag `v1.0.0` → version `1.0.0.post1.devN` (if distance > 0)
82+
- Tag `v1.0.0` → version `1.0.0` (if exact match)
8383

8484
`only-version`
8585
: Only use the version from the tag, as given.
8686

8787
!!! warning "This means version is no longer pseudo unique per commit"
8888

8989
**Examples:**
90-
- Tag `1.0.0` → version `1.0.0` (always, regardless of distance or dirty state)
90+
- Tag `v1.0.0` → version `1.0.0` (always, regardless of distance or dirty state)
9191

9292
`post-release (deprecated)`
9393
: Generates post release versions (adds `.postN`)

docs/index.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,21 @@ dynamic = ["version"]
4343
# more missing
4444

4545
[tool.setuptools_scm]
46+
´´´
4647

47-
```
48+
49+
!!! tip "Recommended Tag Format"
50+
51+
Use the **"v" prefix** for your version tags for best compatibility:
52+
53+
```bash
54+
git tag v1.0.0
55+
git tag v1.1.0
56+
git tag v2.0.0-rc1
57+
```
58+
59+
This is a widely adopted convention that works well with setuptools-scm and other tools.
60+
See the [Version Tag Formats](usage.md#version-tag-formats) section for more details.
4861

4962

5063
### With hatch

docs/overrides.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ Use with a specific package:
5050
export SETUPTOOLS_SCM_PRETEND_METADATA_FOR_MY_PACKAGE='{node="g1234567", distance=2}'
5151
```
5252

53+
!!! note "Node ID Prefixes"
54+
55+
Node IDs must include the appropriate SCM prefix:
56+
57+
- Use `g` prefix for git repositories (e.g., `g1a2b3c4d5`)
58+
- Use `h` prefix for mercurial repositories (e.g., `h1a2b3c4d5`)
59+
60+
This ensures consistency with setuptools-scm's automatic node ID formatting.
61+
5362
### Use case: CI/CD environments
5463

5564
This is particularly useful for solving issues where version file templates need access to

docs/usage.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,100 @@ For Git projects, the version relies on [git describe](https://git-scm.com/docs
253253
so you will see an additional `g` prepended to the `{revision hash}`.
254254

255255

256+
## Version Tag Formats
257+
258+
setuptools-scm automatically detects version information from SCM tags. The default tag regex
259+
supports a wide variety of tag formats, with the **"v" prefix being recommended** for clarity
260+
and consistency.
261+
262+
### Recommended Tag Format
263+
264+
**Use the "v" prefix for version tags:**
265+
266+
```bash
267+
git tag v1.0.0 # Recommended
268+
git tag v2.1.3
269+
git tag v1.0.0-alpha1
270+
git tag v1.0.0-rc1
271+
```
272+
273+
### Supported Tag Formats
274+
275+
setuptools-scm's default tag regex supports:
276+
277+
- **Version prefix**: `v` or `V` (optional, but recommended)
278+
- **Project prefix**: Optional project name followed by dashes (e.g., `myproject-v1.0.0`)
279+
- **Version number**: Standard semantic versioning patterns
280+
- **Pre-release suffixes**: Alpha, beta, RC versions
281+
- **Build metadata**: Anything after `+` is ignored
282+
283+
**Examples of valid tags:**
284+
```bash
285+
# Recommended formats (with v prefix)
286+
v1.0.0
287+
v2.1.3
288+
v1.0.0-alpha1
289+
v1.0.0-beta2
290+
v1.0.0-rc1
291+
v1.2.3-dev
292+
V1.0.0 # Capital V also works
293+
294+
# Project-prefixed formats
295+
myproject-v1.0.0
296+
my-lib-v2.1.0
297+
298+
# Without v prefix (supported but not recommended)
299+
1.0.0
300+
2.1.3
301+
1.0.0-alpha1
302+
303+
# With build metadata (metadata after + is ignored)
304+
v1.0.0+build.123
305+
v1.0.0+20240115
306+
```
307+
308+
### Why Use the "v" Prefix?
309+
310+
1. **Clarity**: Makes it immediately obvious that the tag represents a version
311+
2. **Convention**: Widely adopted standard across the software industry
312+
3. **Git compatibility**: Works well with git's tag sorting and filtering
313+
4. **Tool compatibility**: Many other tools expect version tags to have a "v" prefix
314+
315+
### Custom Tag Patterns
316+
317+
If you need different tag patterns, you can customize the tag regex:
318+
319+
```toml title="pyproject.toml"
320+
[tool.setuptools_scm]
321+
tag_regex = "^release-(?P<version>[0-9]+\\.[0-9]+\\.[0-9]+)$"
322+
```
323+
324+
## Node ID Prefixes
325+
326+
setuptools-scm automatically prepends identifying characters to node IDs (commit/revision hashes)
327+
to distinguish between different SCM systems:
328+
329+
- **Git repositories**: Node IDs are prefixed with `g` (e.g., `g1a2b3c4d5`)
330+
- **Mercurial repositories**: Node IDs are prefixed with `h` (e.g., `h1a2b3c4d5`)
331+
332+
This prefixing serves several purposes:
333+
334+
1. **SCM identification**: Makes it clear which version control system was used
335+
2. **Consistency**: Ensures predictable node ID format across different SCM backends
336+
3. **Debugging**: Helps identify the source SCM when troubleshooting version issues
337+
338+
The prefixes are automatically added by setuptools-scm and should be included when manually
339+
specifying node IDs in environment variables like `SETUPTOOLS_SCM_PRETEND_METADATA`.
340+
341+
**Examples:**
342+
```bash
343+
# Git node ID
344+
1.0.0.dev5+g1a2b3c4d5
345+
346+
# Mercurial node ID
347+
1.0.0.dev5+h1a2b3c4d5
348+
```
349+
256350
!!! note
257351

258352
According to [PEP 440](https://peps.python.org/pep-0440/#local-version-identifiers>),

hatch.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@ python = ["3.8", "3.9", "3.10", "3.11"]
1111
[envs.docs]
1212
python = "3.11"
1313
extras = ["docs"]
14-
dependencies = ["scriv"]
1514

1615
[envs.docs.scripts]
1716
build = "mkdocs build --clean --strict"
1817
serve = "mkdocs serve --dev-addr localhost:8000"
1918
init = "mkdocs {args}"
20-
sync = ["entangled sync"]
21-
22-
changelog-create = "scriv create {args}"
23-
changelog-collect = "scriv collect {args}"
19+
sync = ["entangled sync"]

pyproject.toml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ dependencies = [
4848
'typing-extensions; python_version < "3.10"',
4949
]
5050
[project.optional-dependencies]
51+
rich = [
52+
"rich",
53+
]
54+
toml = [
55+
]
56+
57+
[dependency-groups]
5158
docs = [
5259
#"entangled-cli~=2.0",
5360
"mkdocs",
@@ -57,21 +64,17 @@ docs = [
5764
"mkdocstrings[python]",
5865
"pygments",
5966
]
60-
rich = [
61-
"rich",
62-
]
6367
test = [
6468
"pip",
6569
"build",
6670
"pytest",
71+
"pytest-timeout", # Timeout protection for CI/CD
6772
"rich",
6873
'typing-extensions; python_version < "3.11"',
6974
"wheel",
7075
"griffe",
7176
"flake8",
7277
]
73-
toml = [
74-
]
7578

7679
[project.urls]
7780
documentation = "https://setuptools-scm.readthedocs.io/"
@@ -152,6 +155,7 @@ ignore = ["PP305", "GH103", "GH212", "MY100", "PC111", "PC160", "PC170", "PC180"
152155
[tool.pytest.ini_options]
153156
minversion = "8"
154157
testpaths = ["testing"]
158+
timeout = 300 # 5 minutes timeout per test for CI protection
155159
filterwarnings = [
156160
"error",
157161
"ignore:.*tool\\.setuptools_scm.*",
@@ -166,5 +170,5 @@ markers = [
166170
"skip_commit: allows to skip committing in the helpers",
167171
]
168172

169-
[tool.scriv]
170-
format = "md"
173+
[tool.uv]
174+
default-groups = ["test", "docs"]

0 commit comments

Comments
 (0)