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
+63Lines changed: 63 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -285,6 +285,12 @@ 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
@@ -293,6 +299,63 @@ would be required when not using `setuptools-scm`, namely:
293
299
* To ensure all relevant files are packaged when running the `sdist` command.
294
300
* When using [include_package_data] to include package data as part of the `build` or `bdist_wheel`.
295
301
302
+
#### How it works
303
+
304
+
The file finder integration works through setuptools' plugin system:
305
+
306
+
1.**Entry Point Registration**: setuptools-scm registers itself as a file finder via the `setuptools.file_finders` entry point
307
+
2.**Automatic Discovery**: When setuptools builds a source distribution, it automatically calls setuptools-scm to get the list of files
308
+
3.**SCM Integration**: setuptools-scm queries your SCM (Git, Mercurial) to get all tracked files
309
+
4.**File Inclusion**: All SCM-tracked files are automatically included in the sdist
310
+
311
+
#### Controlling file inclusion
312
+
313
+
**Using MANIFEST.in**: You can still use `MANIFEST.in` to override the automatic behavior:
314
+
315
+
-**Exclude files**: Use `global-exclude` or `exclude` to remove files that are SCM-tracked but shouldn't be in the package
316
+
-**Include additional files**: Use `include` to add files that aren't SCM-tracked
317
+
318
+
```text title="MANIFEST.in"
319
+
# Exclude development files
320
+
exclude *.nix
321
+
exclude .pre-commit-config.yaml
322
+
global-exclude *.pyc
323
+
324
+
# Include additional files not in SCM
325
+
include data/special-file.dat
326
+
```
327
+
328
+
**Example of what gets included automatically**:
329
+
330
+
- All files tracked by Git/Mercurial in your repository
331
+
- Includes source code, data files, documentation, etc.
332
+
- Excludes untracked files and files ignored by your SCM
333
+
334
+
#### Troubleshooting
335
+
336
+
**Too many files in your sdist?**
337
+
338
+
1. Check what's being included: `python -m setuptools_scm ls`
339
+
2. Use `MANIFEST.in` to exclude unwanted files:
340
+
```text
341
+
exclude development-file.txt
342
+
global-exclude *.log
343
+
prune unnecessary-directory/
344
+
```
345
+
346
+
**Files missing from your sdist?**
347
+
348
+
1. Ensure files are tracked by your SCM: `git add` or `hg add`
If you need to completely disable setuptools-scm's file finder (not recommended), you would need to uninstall setuptools-scm from your build environment and handle versioning differently.
358
+
296
359
`MANIFEST.in` may still be used: anything defined there overrides the hook.
297
360
This is mostly useful to exclude files tracked in your SCM from packages,
298
361
although in principle it can be used to explicitly include non-tracked files too.
0 commit comments