You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,8 @@ files that are managed by the SCM
17
17
Unwanted files must be excluded via `MANIFEST.in`
18
18
or [configuring Git archive][git-archive-docs].
19
19
20
+
> **⚠️ Important:** Installing setuptools-scm automatically enables a file finder that includes **all SCM-tracked files** in your source distributions. This can be surprising if you have development files tracked in Git/Mercurial that you don't want in your package. Use `MANIFEST.in` to exclude unwanted files. See the [documentation] for details.
21
+
20
22
## `pyproject.toml` usage
21
23
22
24
The preferred way to configure [setuptools-scm] is to author
Copy file name to clipboardExpand all lines: docs/config.md
+60Lines changed: 60 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -152,6 +152,66 @@ Callables or other Python objects have to be passed in `setup.py` (via the `use_
152
152
153
153
154
154
155
+
## automatic file inclusion
156
+
157
+
!!! warning "Setuptools File Finder Integration"
158
+
159
+
`setuptools-scm` automatically registers a setuptools file finder that includes all SCM-tracked files in source distributions. This behavior is **always active** when setuptools-scm is installed, regardless of whether you use it for versioning.
160
+
161
+
**How it works:**
162
+
163
+
`setuptools-scm` provides a `setuptools.file_finders` entry point that:
- Includes: source code, documentation, tests, config files, etc.
179
+
- Excludes: untracked files, files in `.gitignore`/`.hgignore`
180
+
181
+
**Controlling inclusion:**
182
+
183
+
Use `MANIFEST.in` to override the automatic behavior:
184
+
185
+
```text title="MANIFEST.in"
186
+
# Exclude development files
187
+
exclude .pre-commit-config.yaml
188
+
exclude tox.ini
189
+
global-exclude *.pyc __pycache__/
190
+
191
+
# Exclude entire directories
192
+
prune docs/
193
+
prune testing/
194
+
195
+
# Include non-SCM files
196
+
include data/important.json
197
+
```
198
+
199
+
**Debugging file inclusion:**
200
+
201
+
```bash
202
+
# List files that will be included
203
+
python -m setuptools_scm ls
204
+
205
+
# Build and inspect sdist contents
206
+
python -m build --sdist
207
+
tar -tzf dist/package-*.tar.gz
208
+
```
209
+
210
+
!!! note "Cannot be disabled"
211
+
212
+
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).
Copy file name to clipboardExpand all lines: docs/index.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,16 @@ files that are managed by the SCM
10
10
Unwanted files must be excluded via `MANIFEST.in`
11
11
or [configuring Git archive][git-archive-docs].
12
12
13
+
!!! warning "Automatic File Inclusion Behavior"
14
+
15
+
**Important:** Simply installing `setuptools-scm` as a build dependency will automatically enable its file finder, which includes **all SCM-tracked files** in your source distributions. This happens even if you're not using setuptools-scm for versioning.
16
+
17
+
- ✅ **Expected**: All Git/Mercurial tracked files will be included in your sdist
18
+
- ⚠️ **Surprise**: This includes development files, configs, tests, docs, etc.
19
+
- 🛠️ **Control**: Use `MANIFEST.in` to exclude unwanted files
20
+
21
+
See the [File Finder Documentation](usage.md#file-finders-hook-makes-most-of-manifestin-unnecessary) for details.
Copy file name to clipboardExpand all lines: docs/usage.md
+68-8Lines changed: 68 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -285,17 +285,77 @@ be kept in version control. It's strongly recommended to be put into gitignore.
285
285
286
286
### File finders hook makes most of `MANIFEST.in` unnecessary
287
287
288
+
!!! warning "Automatic File Inclusion"
289
+
290
+
**`setuptools-scm` automatically provides a setuptools file finder by default.** This means that when you install setuptools-scm, it will automatically include **all SCM-tracked files** in your source distributions (sdist) without requiring a `MANIFEST.in` file.
291
+
292
+
This automatic behavior can be surprising if you're not expecting it. The file finder is active as soon as setuptools-scm is installed in your build environment.
293
+
288
294
`setuptools-scm` implements a [file_finders] entry point
289
295
which returns all files tracked by your SCM.
290
296
This eliminates the need for a manually constructed `MANIFEST.in` in most cases where this
291
-
would be required when not using `setuptools-scm`, namely:
297
+
would be required when not using `setuptools-scm`.
1.**Automatic Discovery**: When building source distributions (`python -m build --sdist`), setuptools automatically calls the `setuptools-scm` file finder
304
+
2.**SCM Integration**: The file finder queries your SCM (Git/Mercurial) for all tracked files
305
+
3.**Inclusion**: All tracked files are automatically included in the sdist
306
+
307
+
#### Controlling file inclusion
308
+
309
+
**To exclude unwanted files:**
310
+
311
+
1.**Use `MANIFEST.in`** to exclude specific files/patterns:
3.**Use `.hgignore`** or **Mercurial archive configuration** (for Mercurial repositories)
325
+
326
+
#### Troubleshooting
327
+
328
+
**Problem: Unwanted files in my package**
329
+
- ✅ **Solution**: Add exclusions to `MANIFEST.in`
330
+
- ✅ **Alternative**: Use Git/Mercurial archive configuration
331
+
332
+
**Problem: Missing files in package**
333
+
- ✅ **Check**: Are the files tracked in your SCM?
334
+
- ✅ **Solution**: `git add` missing files or override with `MANIFEST.in`
335
+
336
+
**Problem: File finder not working**
337
+
- ✅ **Check**: Is setuptools-scm installed in your build environment?
338
+
- ✅ **Check**: Are you in a valid SCM repository?
339
+
340
+
### Timestamps for Local Development Versions
341
+
342
+
!!! info "Improved Timestamp Behavior"
343
+
344
+
When your working directory has uncommitted changes (dirty), setuptools-scm now uses the **actual modification time of changed files** instead of the current time for local version schemes like `node-and-date`.
345
+
346
+
**Before**: Dirty working directories always used current time (`now`)
347
+
**Now**: Uses the latest modification time of changed files, falling back to current time only if no changed files are found
348
+
349
+
This provides more stable and meaningful timestamps that reflect when you actually made changes to your code.
350
+
351
+
**How it works:**
292
352
293
-
* To ensure all relevant files are packaged when running the `sdist` command.
294
-
* When using [include_package_data] to include package data as part of the `build` or `bdist_wheel`.
353
+
1.**Clean repository**: Uses commit timestamp from SCM
354
+
2.**Dirty repository**: Uses latest modification time of changed files
355
+
3.**Fallback**: Uses current time if no modification times can be determined
295
356
296
-
`MANIFEST.in` may still be used: anything defined there overrides the hook.
297
-
This is mostly useful to exclude files tracked in your SCM from packages,
298
-
although in principle it can be used to explicitly include non-tracked files too.
0 commit comments