Skip to content

Commit f9a7f4c

Browse files
Update README metadata guidance
1 parent ecf32d9 commit f9a7f4c

1 file changed

Lines changed: 30 additions & 6 deletions

File tree

‎source/guides/making-a-pypi-friendly-readme.rst‎

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,47 @@ Formats supported by `PyPI's README renderer <https://github.com/pypa/readme_ren
1818
* Markdown (`GitHub Flavored Markdown <https://github.github.com/gfm/>`_ by default,
1919
or `CommonMark <https://commonmark.org/>`_)
2020

21-
It's customary to save your README file in the root of your project, in the same directory as your :file:`setup.py` file.
21+
It's customary to save your README file in the root of your project, in the
22+
same directory as your :file:`pyproject.toml` file. Older projects may keep
23+
their README alongside :file:`setup.py` instead.
2224

2325

2426
Including your README in your package's metadata
2527
------------------------------------------------
2628

2729
To include your README's contents as your package description,
28-
set your project's ``Description`` and ``Description-Content-Type`` metadata,
29-
typically in your project's :file:`setup.py` file.
30+
set your project's ``Description`` and ``Description-Content-Type`` metadata.
31+
For modern projects, the recommended way to do this is with the ``readme`` key
32+
in the ``[project]`` table of your :file:`pyproject.toml` file.
3033

3134
.. seealso::
3235

3336
* :ref:`description-optional`
3437
* :ref:`description-content-type-optional`
38+
* :ref:`writing-pyproject-toml`
3539

36-
For example, to set these values in a package's :file:`setup.py` file,
37-
use ``setup()``'s ``long_description`` and ``long_description_content_type``.
40+
For example, to load :file:`README.md` as the project description:
41+
42+
.. code-block:: toml
43+
44+
[project]
45+
readme = "README.md"
46+
47+
The README's format is inferred from common file extensions, such as
48+
``.md`` for Markdown and ``.rst`` for reStructuredText. You can also specify
49+
the content type explicitly:
50+
51+
.. code-block:: toml
52+
53+
[project]
54+
readme = {file = "README.txt", content-type = "text/markdown"}
55+
56+
The file named by ``readme`` should be present in your source distribution so
57+
build tools can read it when they generate the package metadata displayed by
58+
package indexes.
59+
60+
Projects that still configure metadata in :file:`setup.py` can use
61+
``setup()``'s ``long_description`` and ``long_description_content_type``.
3862

3963
Set the value of ``long_description`` to the contents (not the path) of the README file itself.
4064
Set the ``long_description_content_type`` to an accepted ``Content-Type``-style value for your README file's markup,
@@ -69,7 +93,7 @@ such as ``text/plain``, ``text/x-rst`` (for reStructuredText), or ``text/markdow
6993
7094
twine upload dist/*
7195
72-
For example, see this :file:`setup.py` file,
96+
For example, see this older :file:`setup.py` style,
7397
which reads the contents of :file:`README.md` as ``long_description``
7498
and identifies the markup as GitHub-flavored Markdown:
7599

0 commit comments

Comments
 (0)