Skip to content

Commit 7f90733

Browse files
docs: restructure for unified vcs-versioning/setuptools-scm documentation
Reorganize documentation to clearly distinguish between core vcs-versioning features and setuptools-scm specific integration, while maintaining a unified doc set with setuptools-scm as the primary entry point. Major changes: - Add Architecture section to index.md explaining the vcs-versioning core library and setuptools-scm integration layer relationship - Reorganize config.md into clear sections: * Core Configuration: version schemes, tag patterns, fallbacks, etc. * setuptools-scm Specific Configuration: deprecated write_to option * Environment Variables split into Version Detection Overrides and setuptools-scm Overrides - Clean up all docs by removing excessive admonitions - section structure now makes the distinction clear without repetitive labeling - Correct categorization of features: * version_file, version_file_template: core features (not setuptools-scm specific) * relative_to, parse: core parameters (not setuptools-scm specific) * Only write_to remains truly setuptools-scm specific (deprecated) - Streamline overrides.md to explain version detection overrides vs setuptools-scm configuration overrides The documentation now follows a principle: explain the architecture once in index.md, then let section organization speak for itself throughout.
1 parent d18c32e commit 7f90733

File tree

5 files changed

+203
-89
lines changed

5 files changed

+203
-89
lines changed

docs/config.md

Lines changed: 84 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ Use the `[tool.setuptools_scm]` section when you need to:
2727
- Configure fallback behavior (`fallback_version`)
2828
- Or any other non-default behavior
2929

30-
## configuration parameters
30+
## Core Configuration
31+
32+
These configuration options control version inference and formatting behavior.
3133

3234
Configuration parameters can be configured in `pyproject.toml` or `setup.py`.
3335
Callables or other Python objects have to be passed in `setup.py` (via the `use_scm_version` keyword argument).
3436

35-
3637
`root : Path | PathLike[str]`
3738
: Relative path to the SCM root, defaults to `.` and is relative to the file path passed in `relative_to`
3839

@@ -45,36 +46,6 @@ Callables or other Python objects have to be passed in `setup.py` (via the `use_
4546
either an entrypoint name or a callable.
4647
See [Version number construction](extending.md#setuptools_scmlocal_scheme) for predefined implementations.
4748

48-
49-
`version_file: Path | PathLike[str] | None = None`
50-
: A path to a file that gets replaced with a file containing the current
51-
version. It is ideal for creating a ``_version.py`` file within the
52-
package, typically used to avoid using `importlib.metadata`
53-
(which adds some overhead).
54-
55-
!!! warning ""
56-
57-
Only files with `.py` and `.txt` extensions have builtin templates,
58-
for other file types it is necessary to provide `version_file_template`.
59-
60-
`version_file_template: str | None = None`
61-
: A new-style format string taking `version`, `scm_version` and `version_tuple` as parameters.
62-
`version` is the generated next_version as string,
63-
`version_tuple` is a tuple of split numbers/strings and
64-
`scm_version` is the `ScmVersion` instance the current `version` was rendered from
65-
66-
67-
`write_to: Pathlike[str] | Path | None = None`
68-
: (deprecated) legacy option to create a version file relative to the scm root
69-
it's broken for usage from a sdist and fixing it would be a fatal breaking change,
70-
use `version_file` instead.
71-
72-
`relative_to: Path|Pathlike[str] = "pyproject.toml"`
73-
: A file/directory from which the root can be resolved.
74-
Typically called by a script or module that is not in the root of the
75-
repository to point `setuptools_scm` at the root of the repository by
76-
supplying `__file__`.
77-
7849
`tag_regex: str|Pattern[str]`
7950
: A Python regex string to extract the version part from any SCM tag.
8051
The regex needs to contain either a single match group, or a group
@@ -118,11 +89,26 @@ Callables or other Python objects have to be passed in `setup.py` (via the `use_
11889
available, `fallback_root` is used instead. This allows the same configuration
11990
to work in both scenarios without modification.
12091

121-
`parse: Callable[[Path, Config], ScmVersion] | None = None`
122-
: A function that will be used instead of the discovered SCM
123-
for parsing the version. Use with caution,
124-
this is a function for advanced use and you should be
125-
familiar with the `setuptools-scm` internals to use it.
92+
`normalize`
93+
: A boolean flag indicating if the version string should be normalized.
94+
Defaults to `True`. Setting this to `False` is equivalent to setting
95+
`version_cls` to [vcs_versioning.NonNormalizedVersion][]
96+
97+
`version_cls: type|str = packaging.version.Version`
98+
: An optional class used to parse, verify and possibly normalize the version
99+
string. Its constructor should receive a single string argument, and its
100+
`str` should return the normalized version string to use.
101+
This option can also receive a class qualified name as a string.
102+
103+
The [vcs_versioning.NonNormalizedVersion][] convenience class is
104+
provided to disable the normalization step done by
105+
`packaging.version.Version`. If this is used while `setuptools-scm`
106+
is integrated in a setuptools packaging process, the non-normalized
107+
version number will appear in all files (see `version_file` note).
108+
109+
!!! note "normalization still applies to artifact filenames"
110+
Setuptools will still normalize it to create the final distribution,
111+
so as to stay compliant with the python packaging standards.
126112

127113
`scm.git.describe_command`
128114
: This command will be used instead the default `git describe --long` command.
@@ -148,29 +134,49 @@ Callables or other Python objects have to be passed in `setup.py` (via the `use_
148134

149135
This field is maintained for backward compatibility but will issue a deprecation warning when used.
150136

151-
`normalize`
152-
: A boolean flag indicating if the version string should be normalized.
153-
Defaults to `True`. Setting this to `False` is equivalent to setting
154-
`version_cls` to [vcs_versioning.NonNormalizedVersion][]
137+
`relative_to: Path|Pathlike[str] = "pyproject.toml"`
138+
: A file/directory from which the root can be resolved.
139+
Typically called by a script or module that is not in the root of the
140+
repository to point to the root of the repository by
141+
supplying `__file__`.
155142

156-
`version_cls: type|str = packaging.version.Version`
157-
: An optional class used to parse, verify and possibly normalize the version
158-
string. Its constructor should receive a single string argument, and its
159-
`str` should return the normalized version string to use.
160-
This option can also receive a class qualified name as a string.
143+
`parse: Callable[[Path, Config], ScmVersion] | None = None`
144+
: A function that will be used instead of the discovered SCM
145+
for parsing the version. Use with caution,
146+
this is a function for advanced use and you should be
147+
familiar with the vcs-versioning internals to use it.
161148

162-
The [vcs_versioning.NonNormalizedVersion][] convenience class is
163-
provided to disable the normalization step done by
164-
`packaging.version.Version`. If this is used while `setuptools-scm`
165-
is integrated in a setuptools packaging process, the non-normalized
166-
version number will appear in all files (see `version_file` note).
149+
`version_file: Path | PathLike[str] | None = None`
150+
: A path to a file that gets replaced with a file containing the current
151+
version. It is ideal for creating a ``_version.py`` file within the
152+
package, typically used to avoid using `importlib.metadata`
153+
(which adds some overhead).
167154

168-
!!! note "normalization still applies to artifact filenames"
169-
Setuptools will still normalize it to create the final distribution,
170-
so as to stay compliant with the python packaging standards.
155+
!!! warning ""
156+
157+
Only files with `.py` and `.txt` extensions have builtin templates,
158+
for other file types it is necessary to provide `version_file_template`.
159+
160+
`version_file_template: str | None = None`
161+
: A new-style format string taking `version`, `scm_version` and `version_tuple` as parameters.
162+
`version` is the generated next_version as string,
163+
`version_tuple` is a tuple of split numbers/strings and
164+
`scm_version` is the `ScmVersion` instance the current `version` was rendered from
171165

166+
## setuptools-scm Specific Configuration
172167

173-
## environment variables
168+
These options control setuptools integration behavior.
169+
170+
`write_to: Pathlike[str] | Path | None = None`
171+
: (deprecated) legacy option to create a version file relative to the scm root
172+
it's broken for usage from a sdist and fixing it would be a fatal breaking change,
173+
use `version_file` instead.
174+
175+
## Environment Variables
176+
177+
### Version Detection Overrides
178+
179+
These environment variables override version detection behavior.
174180

175181
`SETUPTOOLS_SCM_PRETEND_VERSION`
176182
: used as the primary source for the version number
@@ -193,14 +199,25 @@ Callables or other Python objects have to be passed in `setup.py` (via the `use_
193199

194200
this will take precedence over ``SETUPTOOLS_SCM_PRETEND_VERSION``
195201

202+
`SETUPTOOLS_SCM_PRETEND_METADATA`
203+
: A TOML inline table for overriding individual version metadata fields.
204+
See the [overrides documentation](overrides.md#pretend-metadata-core) for details.
205+
206+
`SETUPTOOLS_SCM_PRETEND_METADATA_FOR_${DIST_NAME}`
207+
: Same as above but specific to a package (recommended over the generic version).
208+
196209
`SETUPTOOLS_SCM_DEBUG`
197-
: enable the debug logging
210+
: Enable debug logging for version detection and processing.
198211

199212
`SOURCE_DATE_EPOCH`
200-
: used as the timestamp from which the
213+
: Used as the timestamp from which the
201214
``node-and-date`` and ``node-and-timestamp`` local parts are
202-
derived, otherwise the current time is used
203-
(https://reproducible-builds.org/docs/source-date-epoch/)
215+
derived, otherwise the current time is used.
216+
Standard environment variable from [reproducible-builds.org](https://reproducible-builds.org/docs/source-date-epoch/).
217+
218+
### setuptools-scm Overrides
219+
220+
These environment variables control setuptools-scm specific behavior.
204221

205222
`SETUPTOOLS_SCM_IGNORE_VCS_ROOTS`
206223
: a ``os.pathsep`` separated list
@@ -211,11 +228,15 @@ Callables or other Python objects have to be passed in `setup.py` (via the `use_
211228

212229
for example, set this to ``chg`` to reduce start-up overhead of Mercurial
213230

231+
`SETUPTOOLS_SCM_OVERRIDES_FOR_${DIST_NAME}`
232+
: A TOML inline table to override configuration from `pyproject.toml`.
233+
See the [overrides documentation](overrides.md#config-overrides) for details.
214234

235+
`SETUPTOOLS_SCM_SUBPROCESS_TIMEOUT`
236+
: Override the subprocess timeout (default: 40 seconds).
237+
See the [overrides documentation](overrides.md#subprocess-timeouts) for details.
215238

216-
217-
218-
## automatic file inclusion
239+
## Automatic File Inclusion
219240

220241
!!! warning "Setuptools File Finder Integration"
221242

@@ -274,8 +295,7 @@ tar -tzf dist/package-*.tar.gz
274295

275296
The file finder cannot be disabled through configuration - it's automatically active when setuptools-scm is installed. If you need to disable it completely, you must remove setuptools-scm from your build environment (which also means you can't use it for versioning).
276297

277-
278-
## api reference
298+
## API Reference
279299

280300
### constants
281301

docs/extending.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@
3939

4040
## Version number construction
4141

42-
43-
44-
45-
4642
### `setuptools_scm.version_scheme`
4743
Configures how the version number is constructed given a
4844
[ScmVersion][vcs_versioning.ScmVersion] instance and should return a string

docs/index.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,26 @@ or [configuring Git archive][git-archive-docs].
2222

2323
[git-archive-docs]: usage.md#builtin-mechanisms-for-obtaining-version-numbers
2424

25+
## Architecture
26+
27+
`setuptools-scm` is built on top of [`vcs-versioning`](https://pypi.org/project/vcs-versioning/),
28+
a standalone library that provides the core VCS version extraction and formatting functionality.
29+
30+
**vcs-versioning** (core library):
31+
: Handles version extraction from Git and Mercurial repositories, version scheme logic,
32+
tag parsing, and version formatting. These are universal concepts that work across
33+
different build systems and integrations.
34+
35+
**setuptools-scm** (integration layer):
36+
: Provides setuptools-specific features like build-time integration, automatic file
37+
finder registration, and version file generation during package builds.
38+
39+
!!! info "Understanding the documentation"
40+
41+
Most configuration options documented here are **core vcs-versioning features** that
42+
work universally. Features specific to setuptools-scm integration (like automatic
43+
file finders or version file writing) are clearly marked throughout the documentation.
44+
2545
## Basic usage
2646

2747
### With setuptools

0 commit comments

Comments
 (0)