Skip to content

Document warnings on how to set (long_)description #645

Closed

Description

@ComFreek

I have just spent >= 1 hour to overcome this bug: pypa/twine#454

  • In the description argument passed to setup(...), you must not pass newlines!

    (Especially I passed __doc__, which starts of course with a newline most of the time.)
  • In the long_description argument passed to setup(...), you must use LF newlines (\n) exclusively. (No \n! No \r!)

    I suggest doing
    # Open readme with original (i.e. LF) newlines
    # to prevent the all too common "`long_description_content_type` missing"
    # bug (https://github.com/pypa/twine/issues/454)
    with open('README.md', 'r', newline='', encoding='utf-8') as readme_file:
    	long_description = readme_file.read()
    	long_description_content_type = 'text/markdown'
    
    setup(
    	# ...
    	long_description = long_description,
    	long_description_content_type = long_description_content_type,
    )

This should be documented in https://packaging.python.org/tutorials/packaging-projects/.

Activity

  1. rgommers commented on Nov 10, 2026

    @rgommers
    Contributor

    This issue is stale, and therefore I'll close it. The issue is no longer relevant, and the docs on this topic are better (e.g., #2146 documents the modern way to include one's README via pyproject.toml). Thanks for opening the issue @ComFreek

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions