Skip to content

long_description vs. pyproject.toml #1535

Open
@0cjs

Description

@0cjs

I recently uploaded my first package to PyPI and immediately discovered that I didn't get the nice long description that all the other packages have. As it turns out, this is because I didn't have a long_description field set when uploading, which was news to me. I feel that the the basic "Here's how you set up your first pyproject.toml" instructions should include something about that (properly explained in light of further notes below).

I can't recall now where I was sent in this documentation to fix this (or how I got to a link that sent me there), but I think I eventually ended up at Making a PyPI-friendly README, which is clearly relevant documentation. However, this mentions nothing about pyproject.toml and only suggests that you add Python code to setup.py that does a read_text() on README.md, and manually pass that and long_description_content_type='text/markdown' to the setup() function.

After some searching about, it appears that the correct (and far easier) way to do this is simply to add readme = 'README.md' to the [project] section of pyproject.toml, which will set long_description to the contents of that file and, based on the extension, long_description_content_type = 'text/markdown'.

This should be documented there, and somewhere (possibly on the same page) should be an explanation that this generates the long description section on PyPI.org.

Ideally, there would also be something somewhere that shows how to generate the stuff that appears in the left-hand bar on PyPI.org, too, such as the home page, GitHub repo, etc.

#971 may be related to this, though that's about two and a half years old and is talking about using setup.cfg rather than pyproject.toml.

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: guidestype: taskSomething that needs to be done that is not a bug or feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions