Skip to content

Commit 3baa398

Browse files
Merge pull request #1202 from RonnyPfannschmidt/version-infer-again
reiterate version inference
2 parents 861df20 + b8a2920 commit 3baa398

25 files changed

+1155
-1242
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,5 @@ coverage.xml
5151

5252
# Sphinx documentation
5353
docs/_build/
54+
55+
.serena/cache/

.serena/memories/done_checklist.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Before considering a task done
2+
3+
- Code quality
4+
- Ruff clean: uv run ruff check .
5+
- Types clean: uv run mypy
6+
- Tests
7+
- All tests green: uv run pytest
8+
- New/changed behavior covered with tests (use project fixtures)
9+
- Docs
10+
- Update docs if user-facing behavior changed
11+
- Build docs cleanly: uv run mkdocs build --clean --strict
12+
- Packaging
13+
- If relevant: uv run python -m build && uv run twine check dist/*
14+
- Housekeeping
15+
- Follow existing naming and module structure; keep functions focused and typed
16+
- Update `CHANGELOG.md` when appropriate

.serena/memories/project_overview.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Project: setuptools-scm
2+
3+
Purpose
4+
- Extract and infer Python package versions from SCM metadata (Git/Mercurial) at build/runtime.
5+
- Provide setuptools integrations (dynamic version, file finders) and fallbacks for archival/PKG-INFO.
6+
7+
Tech Stack
8+
- Language: Python (3.8–3.13)
9+
- Packaging/build: setuptools (>=61), packaging; console scripts via entry points
10+
- Tooling: uv (dependency and run), pytest, mypy (strict), ruff (lint, isort), mkdocs (docs), tox (optional/matrix), wheel/build
11+
12+
Codebase Structure (high level)
13+
- src/setuptools_scm/: library code
14+
- _cli.py, __main__.py: CLI entry (`python -m setuptools_scm`, `setuptools-scm`)
15+
- git.py, hg.py, hg_git.py: VCS parsing
16+
- _file_finders/: discover files for sdist
17+
- _integration/: setuptools and pyproject integration
18+
- version.py and helpers: version schemes/local version logic
19+
- discover.py, fallbacks.py: inference and archival fallbacks
20+
- testing/: pytest suite and fixtures
21+
- docs/: mkdocs documentation
22+
- pyproject.toml: project metadata, pytest and ruff config
23+
- tox.ini: alternate CI/matrix, flake8 defaults
24+
- uv.lock: locked dependencies
25+
26+
Conventions
27+
- Use uv to run commands (`uv run ...`); tests live under `testing/` per pytest config.
28+
- Type hints throughout; strict mypy enforced; ruff governs lint rules and import layout (isort in ruff).
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Style and Conventions
2+
3+
- Typing
4+
- mypy strict is enabled; add precise type hints for public functions/classes.
5+
- Prefer explicit/clear types; avoid `Any` and unsafe casts.
6+
- Linting/Imports
7+
- Ruff is the canonical linter (config in pyproject). Respect its rules and isort settings (single-line imports, ordered, types grouped).
8+
- Flake8 config exists in tox.ini but ruff linting is primary.
9+
- Formatting
10+
- Follow ruff guidance; keep lines <= 88 where applicable (flake8 reference).
11+
- Testing
12+
- Pytest with `testing/` as testpath; default 5m timeout; warnings treated as errors.
13+
- Use existing fixtures; add `@pytest.mark` markers if needed (see pyproject markers).
14+
- Logging
15+
- Tests run with log level info/debug; avoid noisy logs in normal library code.
16+
- General
17+
- Small, focused functions; early returns; explicit errors. Keep APIs documented with concise docstrings.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Environment
2+
- Install deps (uses default groups test, docs):
3+
- uv sync
4+
5+
Core Dev
6+
- Run tests:
7+
- uv run pytest
8+
- Lint (ruff):
9+
- uv run ruff check .
10+
- uv run ruff check . --fix # optional autofix
11+
- Type check (mypy strict):
12+
- uv run mypy
13+
- Build docs:
14+
- uv run mkdocs serve --dev-addr localhost:8000
15+
- uv run mkdocs build --clean --strict
16+
17+
Entrypoints / Tooling
18+
- CLI version/debug:
19+
- uv run python -m setuptools_scm --help
20+
- uv run python -m setuptools_scm
21+
- uv run setuptools-scm --help
22+
- Build dist and verify:
23+
- uv run python -m build
24+
- uv run twine check dist/*
25+
- Optional matrix via tox:
26+
- uv run tox -q
27+
28+
Git/Linux Utilities (Linux host)
29+
- git status / git log --oneline --graph --decorate
30+
- ls -la; find . -name "pattern"; grep -R "text" .

.serena/project.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# language of the project (csharp, python, rust, java, typescript, go, cpp, or ruby)
2+
# * For C, use cpp
3+
# * For JavaScript, use typescript
4+
# Special requirements:
5+
# * csharp: Requires the presence of a .sln file in the project folder.
6+
language: python
7+
8+
# whether to use the project's gitignore file to ignore files
9+
# Added on 2025-04-07
10+
ignore_all_files_in_gitignore: true
11+
# list of additional paths to ignore
12+
# same syntax as gitignore, so you can use * and **
13+
# Was previously called `ignored_dirs`, please update your config if you are using that.
14+
# Added (renamed)on 2025-04-07
15+
ignored_paths: []
16+
17+
# whether the project is in read-only mode
18+
# If set to true, all editing tools will be disabled and attempts to use them will result in an error
19+
# Added on 2025-04-18
20+
read_only: false
21+
22+
23+
# list of tool names to exclude. We recommend not excluding any tools, see the readme for more details.
24+
# Below is the complete list of tools for convenience.
25+
# To make sure you have the latest list of tools, and to view their descriptions,
26+
# execute `uv run scripts/print_tool_overview.py`.
27+
#
28+
# * `activate_project`: Activates a project by name.
29+
# * `check_onboarding_performed`: Checks whether project onboarding was already performed.
30+
# * `create_text_file`: Creates/overwrites a file in the project directory.
31+
# * `delete_lines`: Deletes a range of lines within a file.
32+
# * `delete_memory`: Deletes a memory from Serena's project-specific memory store.
33+
# * `execute_shell_command`: Executes a shell command.
34+
# * `find_referencing_code_snippets`: Finds code snippets in which the symbol at the given location is referenced.
35+
# * `find_referencing_symbols`: Finds symbols that reference the symbol at the given location (optionally filtered by type).
36+
# * `find_symbol`: Performs a global (or local) search for symbols with/containing a given name/substring (optionally filtered by type).
37+
# * `get_current_config`: Prints the current configuration of the agent, including the active and available projects, tools, contexts, and modes.
38+
# * `get_symbols_overview`: Gets an overview of the top-level symbols defined in a given file or directory.
39+
# * `initial_instructions`: Gets the initial instructions for the current project.
40+
# Should only be used in settings where the system prompt cannot be set,
41+
# e.g. in clients you have no control over, like Claude Desktop.
42+
# * `insert_after_symbol`: Inserts content after the end of the definition of a given symbol.
43+
# * `insert_at_line`: Inserts content at a given line in a file.
44+
# * `insert_before_symbol`: Inserts content before the beginning of the definition of a given symbol.
45+
# * `list_dir`: Lists files and directories in the given directory (optionally with recursion).
46+
# * `list_memories`: Lists memories in Serena's project-specific memory store.
47+
# * `onboarding`: Performs onboarding (identifying the project structure and essential tasks, e.g. for testing or building).
48+
# * `prepare_for_new_conversation`: Provides instructions for preparing for a new conversation (in order to continue with the necessary context).
49+
# * `read_file`: Reads a file within the project directory.
50+
# * `read_memory`: Reads the memory with the given name from Serena's project-specific memory store.
51+
# * `remove_project`: Removes a project from the Serena configuration.
52+
# * `replace_lines`: Replaces a range of lines within a file with new content.
53+
# * `replace_symbol_body`: Replaces the full definition of a symbol.
54+
# * `restart_language_server`: Restarts the language server, may be necessary when edits not through Serena happen.
55+
# * `search_for_pattern`: Performs a search for a pattern in the project.
56+
# * `summarize_changes`: Provides instructions for summarizing the changes made to the codebase.
57+
# * `switch_modes`: Activates modes by providing a list of their names
58+
# * `think_about_collected_information`: Thinking tool for pondering the completeness of collected information.
59+
# * `think_about_task_adherence`: Thinking tool for determining whether the agent is still on track with the current task.
60+
# * `think_about_whether_you_are_done`: Thinking tool for determining whether the task is truly completed.
61+
# * `write_memory`: Writes a named memory (for future reference) to Serena's project-specific memory store.
62+
excluded_tools: []
63+
64+
# initial prompt for the project. It will always be given to the LLM upon activating the project
65+
# (contrary to the memories, which are loaded on demand).
66+
initial_prompt: ""
67+
68+
project_name: "setuptools_scm"

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Added
6+
7+
- add simplified activation via `setuptools-scm[simple]` extra
8+
9+
A new streamlined way to enable version inference without requiring a `[tool.setuptools_scm]` section.
10+
When `setuptools-scm[simple]` is in `build-system.requires` and `version` is in `project.dynamic`,
11+
version inference is automatically enabled with default settings.
12+
13+
14+
### removed
15+
16+
- unchecked simplified activation - too many projects use setups where it would fail
17+
18+
319
## v9.1.1
420

521
### fixed

docs/config.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,25 @@
22

33
## When is configuration needed?
44

5-
Starting with setuptools-scm 8.1+, explicit configuration is **optional** in many cases:
5+
setuptools-scm provides flexible activation options:
66

7-
- **No configuration needed**: If `setuptools_scm` (or `setuptools-scm`) is in your `build-system.requires`, setuptools-scm will automatically activate with sensible defaults.
7+
### Simplified Activation (No Configuration Needed)
88

9-
- **Configuration recommended**: Use the `[tool.setuptools_scm]` section when you need to:
9+
For basic usage, use the `simple` extra with no configuration:
10+
11+
```toml title="pyproject.toml"
12+
[build-system]
13+
requires = ["setuptools>=80", "setuptools-scm[simple]>=8"]
14+
15+
[project]
16+
dynamic = ["version"]
17+
```
18+
19+
This automatically enables version inference with default settings.
20+
21+
### Explicit Configuration (Full Control)
22+
23+
Use the `[tool.setuptools_scm]` section when you need to:
1024
- Write version files (`version_file`)
1125
- Customize version schemes (`version_scheme`, `local_scheme`)
1226
- Set custom tag patterns (`tag_regex`)

docs/index.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,36 @@ Note: `setuptools-scm>=8` intentionally doesn't depend on setuptools to ease non
3030
Please ensure a recent version of setuptools is installed (minimum: >=61, recommended: >=80 for best compatibility).
3131
Support for setuptools <80 is deprecated and will be removed in a future release.
3232

33+
**Simplified setup (recommended for basic usage):**
3334

3435
```toml title="pyproject.toml"
3536
[build-system]
36-
requires = ["setuptools>=80", "setuptools-scm>=8"]
37+
requires = ["setuptools>=80", "setuptools-scm[simple]>=8"]
3738
build-backend = "setuptools.build_meta"
3839

3940
[project]
4041
name = "example"
4142
# Important: Remove any existing version declaration
4243
# version = "0.0.1"
4344
dynamic = ["version"]
44-
# more missing
45+
46+
# No additional configuration needed!
47+
```
48+
49+
**With custom configuration:**
50+
51+
```toml title="pyproject.toml"
52+
[build-system]
53+
requires = ["setuptools>=80", "setuptools-scm>=8"]
54+
build-backend = "setuptools.build_meta"
55+
56+
[project]
57+
name = "example"
58+
dynamic = ["version"]
4559

4660
[tool.setuptools_scm]
47-
´´´
61+
# Custom configuration options go here
62+
```
4863

4964

5065
!!! tip "Recommended Tag Format"

docs/usage.md

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,40 @@
77
Support for setuptools <80 is deprecated and will be removed in a future release.
88
The examples below use `setuptools>=80` as the recommended version.
99

10-
There are two ways to configure `setuptools-scm` at build time, depending on your needs:
10+
There are three ways to enable `setuptools-scm` at build time:
1111

12-
### Automatic Configuration (Recommended for Simple Cases)
12+
### Simplified Activation (new)
1313

14-
For projects that don't need custom configuration, simply include `setuptools-scm`
15-
in your build requirements:
14+
For basic usage without custom configuration, use the `simple` extra:
1615

1716
```toml title="pyproject.toml"
1817
[build-system]
19-
requires = ["setuptools>=80", "setuptools-scm>=8"]
18+
requires = ["setuptools>=80", "setuptools-scm[simple]>=8"]
2019
build-backend = "setuptools.build_meta"
2120

2221
[project]
2322
# version = "0.0.1" # Remove any existing version parameter.
2423
dynamic = ["version"]
24+
25+
# No [tool.setuptools_scm] section needed for basic usage!
2526
```
2627

27-
**That's it!** Starting with setuptools-scm 8.1+, if `setuptools_scm` (or `setuptools-scm`)
28-
is present in your `build-system.requires`, setuptools-scm will automatically activate
29-
with default settings.
28+
This streamlined approach automatically enables version inference when:
29+
- `setuptools-scm[simple]` is listed in `build-system.requires`
30+
- `version` is included in `project.dynamic`
31+
32+
!!! tip "When to use simplified activation"
3033

31-
### Explicit Configuration
34+
Use simplified activation when you:
35+
- Want basic SCM version inference with default settings
36+
- Don't need custom version schemes or file writing
37+
- Prefer minimal configuration
3238

33-
If you need to customize setuptools-scm behavior, use the `tool.setuptools_scm` section:
39+
Upgrade to explicit configuration if you need customization.
40+
41+
### Explicit Configuration (full control)
42+
43+
Add a `tool.setuptools_scm` section for custom configuration:
3444

3545
```toml title="pyproject.toml"
3646
[build-system]
@@ -51,20 +61,25 @@ pre_parse = "fail_on_missing_submodules" # Fail if submodules are not initializ
5161
describe_command = "git describe --dirty --tags --long --exclude *js*" # Custom describe command
5262
```
5363

54-
Both approaches will work with projects that support PEP 518 ([pip](https://pypi.org/project/pip) and
55-
[pep517](https://pypi.org/project/pep517/)).
56-
Tools that still invoke `setup.py` must ensure build requirements are installed
64+
Projects must support PEP 518 ([pip](https://pypi.org/project/pip) and
65+
[pep517](https://pypi.org/project/pep517/)). Tools that still invoke `setup.py`
66+
must ensure build requirements are installed.
67+
68+
### Using the setup keyword
5769

58-
!!! info "How Automatic Detection Works"
70+
Alternatively, enable `setuptools-scm` via the `use_scm_version` keyword in `setup.py`.
71+
This also counts as an explicit opt-in and does not require a tool section.
5972

60-
When setuptools-scm is listed in `build-system.requires`, it automatically detects this during the build process and activates with default settings. This means:
73+
!!! note "Legacy simplified activation"
6174

62-
- ✅ **Automatic activation**: No `[tool.setuptools_scm]` section needed
63-
- ✅ **Default behavior**: Uses standard version schemes and SCM detection
64-
- ✅ **Error handling**: Provides helpful error messages if configuration is missing
65-
- ⚙️ **Customization**: Add `[tool.setuptools_scm]` section when you need custom options
75+
Previous versions had a "simplified" activation where listing `setuptools_scm`
76+
in `build-system.requires` together with `project.dynamic = ["version"]` would
77+
auto-enable version inference. This behavior was removed due to regressions and
78+
ambiguous activation.
6679

67-
Both package names are detected: `setuptools_scm` and `setuptools-scm` (with dash).
80+
The new simplified activation using the `[simple]` extra provides the same
81+
convenience but with explicit opt-in, making it clear when version inference
82+
should be enabled.
6883

6984
### Version files
7085

0 commit comments

Comments
 (0)