Search code examples
pythonsetuptoolssetup.pypypitwine

twine: warning: `long_description_content_type` missing


This is what my setup.py looks like:

from distutils.core import setup

setup(
    author='...',
    description='...',
    download_url='...',
    license='...',
    long_description=open('README.md', 'r').read(),
    long_description_content_type='text/markdown',
    name='...',
    packages=['...'],
    url='...',
    version='...'
)

Then, I can run python setup.py sdist without any errors. But if I check the package with twine (twine check dist/*), I get the following warning:

 `long_description` has syntax errors in markup and would not be rendered on PyPI.
  warning: `long_description_content_type` missing. defaulting to `text/x-rst`.

All of my packages are up to date, and I have no duplicate or multi-line attributes. What is causing this, and how can I fix it?


Solution

  • This is because you're using the setup function provided by distutils.core. Use setuptools instead:

    from setuptools import setup
    

    distutils.core doesn't expect the long_description_content_type to be provided, and seemingly ignores it. It actually says this when you run setup.py:

    UserWarning: Unknown distribution option: 'long_description_content_type'
    

    Although that's easy to miss, since it's at the top of a long block of otherwise error-free logs.