Skip to content

Commit 8b2e751

Browse files
add docs for the now optional tool section
1 parent e4cd419 commit 8b2e751

File tree

3 files changed

+67
-6
lines changed

3 files changed

+67
-6
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@ dynamic = ["version"]
5353
[tool.setuptools_scm]
5454
```
5555

56+
!!! note "Simplified Configuration"
57+
58+
Starting with setuptools-scm 8.1+, if `setuptools_scm` (or `setuptools-scm`) is
59+
present in your `build-system.requires`, the `[tool.setuptools_scm]` section
60+
becomes optional! You can now enable setuptools-scm with just:
61+
62+
```toml title="pyproject.toml"
63+
[build-system]
64+
requires = ["setuptools>=64", "setuptools-scm>=8"]
65+
build-backend = "setuptools.build_meta"
66+
67+
[project]
68+
dynamic = ["version"]
69+
```
70+
71+
The `[tool.setuptools_scm]` section is only needed if you want to customize
72+
configuration options.
73+
5674
Additionally, a version file can be written by specifying:
5775

5876
```toml title="pyproject.toml"

docs/config.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Configuration
22

3+
## When is configuration needed?
4+
5+
Starting with setuptools-scm 8.1+, explicit configuration is **optional** in many cases:
6+
7+
- **No configuration needed**: If `setuptools_scm` (or `setuptools-scm`) is in your `build-system.requires`, setuptools-scm will automatically activate with sensible defaults.
8+
9+
- **Configuration recommended**: Use the `[tool.setuptools_scm]` section when you need to:
10+
- Write version files (`version_file`)
11+
- Customize version schemes (`version_scheme`, `local_scheme`)
12+
- Set custom tag patterns (`tag_regex`)
13+
- Configure fallback behavior (`fallback_version`)
14+
- Or any other non-default behavior
315

416
## configuration parameters
517

docs/usage.md

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,30 @@
22

33
## At build time
44

5-
The preferred way to configure `setuptools-scm` is to author
6-
settings in the `tool.setuptools_scm` section of `pyproject.toml`.
5+
There are two ways to configure `setuptools-scm` at build time, depending on your needs:
76

8-
It's necessary to use a setuptools version released after 2022.
7+
### Automatic Configuration (Recommended for Simple Cases)
8+
9+
For projects that don't need custom configuration, simply include `setuptools-scm`
10+
in your build requirements:
11+
12+
```toml title="pyproject.toml"
13+
[build-system]
14+
requires = ["setuptools>=64", "setuptools-scm>=8"]
15+
build-backend = "setuptools.build_meta"
16+
17+
[project]
18+
# version = "0.0.1" # Remove any existing version parameter.
19+
dynamic = ["version"]
20+
```
21+
22+
**That's it!** Starting with setuptools-scm 8.1+, if `setuptools_scm` (or `setuptools-scm`)
23+
is present in your `build-system.requires`, setuptools-scm will automatically activate
24+
with default settings.
25+
26+
### Explicit Configuration
27+
28+
If you need to customize setuptools-scm behavior, use the `tool.setuptools_scm` section:
929

1030
```toml title="pyproject.toml"
1131
[build-system]
@@ -17,14 +37,25 @@ build-backend = "setuptools.build_meta"
1737
dynamic = ["version"]
1838

1939
[tool.setuptools_scm]
20-
# can be empty if no extra settings are needed, presence enables setuptools-scm
40+
# Configure custom options here (version schemes, file writing, etc.)
41+
version_file = "src/mypackage/_version.py"
2142
```
2243

23-
That will be sufficient to require `setuptools-scm` for projects
24-
that support PEP 518 ([pip](https://pypi.org/project/pip) and
44+
Both approaches will work with projects that support PEP 518 ([pip](https://pypi.org/project/pip) and
2545
[pep517](https://pypi.org/project/pep517/)).
2646
Tools that still invoke `setup.py` must ensure build requirements are installed
2747

48+
!!! info "How Automatic Detection Works"
49+
50+
When setuptools-scm is listed in `build-system.requires`, it automatically detects this during the build process and activates with default settings. This means:
51+
52+
- ✅ **Automatic activation**: No `[tool.setuptools_scm]` section needed
53+
- ✅ **Default behavior**: Uses standard version schemes and SCM detection
54+
- ✅ **Error handling**: Provides helpful error messages if configuration is missing
55+
- ⚙️ **Customization**: Add `[tool.setuptools_scm]` section when you need custom options
56+
57+
Both package names are detected: `setuptools_scm` and `setuptools-scm` (with dash).
58+
2859
### Version files
2960

3061
Version files can be created with the ``version_file`` directive.

0 commit comments

Comments
 (0)