|
1 |
| -.. _`Using MANIFEST.in`: |
| 1 | +:orphan: |
2 | 2 |
|
3 | 3 | ============================================================
|
4 | 4 | Including files in source distributions with ``MANIFEST.in``
|
5 | 5 | ============================================================
|
6 | 6 |
|
7 |
| -When building a :term:`source distribution <Source Distribution (or "sdist")>` |
8 |
| -for your package, by default only a minimal set of files are included. You may |
9 |
| -find yourself wanting to include extra files in the source distribution, such |
10 |
| -as an authors/contributors file, a :file:`docs/` directory, or a directory of |
11 |
| -data files used for testing purposes. There may even be extra files that you |
12 |
| -*need* to include; for example, if your :file:`setup.py` computes your |
13 |
| -project's ``long_description`` by reading from both a README and a changelog |
14 |
| -file, you'll need to include both those files in the sdist so that people that |
15 |
| -build or install from the sdist get the correct results. |
16 |
| - |
17 |
| -Adding & removing files to & from the source distribution is done by writing a |
18 |
| -:file:`MANIFEST.in` file at the project root. |
19 |
| - |
20 |
| - |
21 |
| -How files are included in an sdist |
22 |
| -================================== |
23 |
| - |
24 |
| -The following files are included in a source distribution by default: |
25 |
| - |
26 |
| -- all Python source files implied by the ``py_modules`` and ``packages`` |
27 |
| - ``setup()`` arguments |
28 |
| -- all C source files mentioned in the ``ext_modules`` or ``libraries`` |
29 |
| - ``setup()`` arguments |
30 |
| -- scripts specified by the ``scripts`` ``setup()`` argument |
31 |
| -- all files specified by the ``package_data`` and ``data_files`` ``setup()`` |
32 |
| - arguments |
33 |
| -- the file specified by the ``license_file`` option in :file:`setup.cfg` |
34 |
| - (setuptools 40.8.0+) |
35 |
| -- all files specified by the ``license_files`` option in :file:`setup.cfg` |
36 |
| - (setuptools 42.0.0+) |
37 |
| -- all files matching the pattern :file:`test/test*.py` |
38 |
| -- :file:`setup.py` (or whatever you called your setup script) |
39 |
| -- :file:`setup.cfg` |
40 |
| -- :file:`README` |
41 |
| -- :file:`README.txt` |
42 |
| -- :file:`README.rst` (Python 3.7+ or setuptools 0.6.27+) |
43 |
| -- :file:`README.md` (setuptools 36.4.0+) |
44 |
| -- :file:`pyproject.toml` (setuptools 43.0.0+) |
45 |
| -- :file:`MANIFEST.in` |
46 |
| - |
47 |
| -After adding the above files to the sdist, the commands in :file:`MANIFEST.in` |
48 |
| -(if such a file exists) are executed in order to add and remove further files |
49 |
| -to and from the sdist. Default files can even be removed from the sdist with the |
50 |
| -appropriate :file:`MANIFEST.in` command. |
51 |
| - |
52 |
| -After processing the :file:`MANIFEST.in` file, setuptools removes the |
53 |
| -:file:`build/` directory as well as any directories named :file:`RCS`, |
54 |
| -:file:`CVS`, or :file:`.svn` from the sdist, and it adds a :file:`PKG-INFO` |
55 |
| -file and an :file:`*.egg-info` directory. This behavior cannot be changed with |
56 |
| -:file:`MANIFEST.in`. |
57 |
| - |
58 |
| - |
59 |
| -:file:`MANIFEST.in` commands |
60 |
| -============================ |
61 |
| - |
62 |
| -A :file:`MANIFEST.in` file consists of commands, one per line, instructing |
63 |
| -setuptools to add or remove some set of files from the sdist. The commands |
64 |
| -are: |
65 |
| - |
66 |
| -========================================================= ================================================================================================== |
67 |
| -Command Description |
68 |
| -========================================================= ================================================================================================== |
69 |
| -:samp:`include {pat1} {pat2} ...` Add all files matching any of the listed patterns |
70 |
| - (Files must be given as paths relative to the root of the project) |
71 |
| -:samp:`exclude {pat1} {pat2} ...` Remove all files matching any of the listed patterns |
72 |
| - (Files must be given as paths relative to the root of the project) |
73 |
| -:samp:`recursive-include {dir-pattern} {pat1} {pat2} ...` Add all files under directories matching ``dir-pattern`` that match any of the listed patterns |
74 |
| -:samp:`recursive-exclude {dir-pattern} {pat1} {pat2} ...` Remove all files under directories matching ``dir-pattern`` that match any of the listed patterns |
75 |
| -:samp:`global-include {pat1} {pat2} ...` Add all files anywhere in the source tree matching any of the listed patterns |
76 |
| -:samp:`global-exclude {pat1} {pat2} ...` Remove all files anywhere in the source tree matching any of the listed patterns |
77 |
| -:samp:`graft {dir-pattern}` Add all files under directories matching ``dir-pattern`` |
78 |
| -:samp:`prune {dir-pattern}` Remove all files under directories matching ``dir-pattern`` |
79 |
| -========================================================= ================================================================================================== |
80 |
| - |
81 |
| -The patterns here are glob-style patterns: ``*`` matches zero or more regular |
82 |
| -filename characters (on Unix, everything except forward slash; on Windows, |
83 |
| -everything except backslash and colon); ``?`` matches a single regular filename |
84 |
| -character, and ``[chars]`` matches any one of the characters between the square |
85 |
| -brackets (which may contain character ranges, e.g., ``[a-z]`` or |
86 |
| -``[a-fA-F0-9]``). Setuptools also has undocumented support for ``**`` matching |
87 |
| -zero or more characters including forward slash, backslash, and colon. |
88 |
| - |
89 |
| -Directory patterns are relative to the root of the project directory; e.g., |
90 |
| -``graft example*`` will include a directory named :file:`examples` in the |
91 |
| -project root but will not include :file:`docs/examples/`. |
92 |
| - |
93 |
| -File & directory names in :file:`MANIFEST.in` should be ``/``-separated; |
94 |
| -setuptools will automatically convert the slashes to the local platform's |
95 |
| -appropriate directory separator. |
96 |
| - |
97 |
| -Commands are processed in the order they appear in the :file:`MANIFEST.in` |
98 |
| -file. For example, given the commands: |
99 |
| - |
100 |
| -.. code-block:: bash |
101 |
| -
|
102 |
| - graft tests |
103 |
| - global-exclude *.py[cod] |
104 |
| -
|
105 |
| -the contents of the directory tree :file:`tests` will first be added to the |
106 |
| -sdist, and then after that all files in the sdist with a ``.pyc``, ``.pyo``, or |
107 |
| -``.pyd`` extension will be removed from the sdist. If the commands were in the |
108 |
| -opposite order, then ``*.pyc`` files etc. would be only be removed from what |
109 |
| -was already in the sdist before adding :file:`tests`, and if :file:`tests` |
110 |
| -happened to contain any ``*.pyc`` files, they would end up included in the |
111 |
| -sdist because the exclusion happened before they were included. |
| 7 | +The information on this page has moved to |
| 8 | +:doc:`setuptools:userguide/miscellaneous` in the setuptools |
| 9 | +documentation. |
0 commit comments