麻线:警告:缺少“ long_description_content_type”

问题描述

这是我的setup.py的样子:

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='...'
)

然后,我可以运行python setup.py sdist,而不会出现任何错误。但是,如果我用麻线(twine check dist/*)检查包裹,则会收到以下警告:

 `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`.

我的所有软件包都是最新的,并且我没有重复或多行属性。是什么原因造成的,我该如何解决

解决方法

这是因为您正在使用distutils.core提供的设置功能。请改用setuptools

from setuptools import setup

distutils.core并不期望提供long_description_content_type,并且似乎忽略了它。它实际上是在运行setup.py时说的:

UserWarning: Unknown distribution option: 'long_description_content_type'

尽管很容易遗漏,因为它位于一堆没有错误的日志的顶部。