这是我的设置
setup(
name="`...",
version="...",
description=...,
long_description_content_type="text/markdown",
long_description=README,
author="...",
classifiers=[...],
packages=["..."],
include_package_data=True,
)
我使用以下命令来打包我的项目
python setup.py sdist bdist_wheel
但是当我运行时
twine check dist/*
我得到以下错误
Checking distFutshane_TBG-1.0.0-py3-none-any.whl: FAILED
`long_description` has syntax errors in markup and would not be rendered on PyPI.
line 9: Error: Unexpected indentation.
warning: `long_description_content_type` missing. defaulting to `text/x-rst`.
Checking distFutshane_TBG-1.0.0.tar.gz: FAILED
`long_description` has syntax errors in markup and would not be rendered on PyPI.
line 9: Error: Unexpected indentation.
warning: `long_description_content_type` missing. defaulting to `text/x-rst`.
为什么它不能识别所提供的类型,而我显然已经提供了一个?
我试图切换";longdescription_content_type"以及";long_description"参数,而不是将描述参数分配给包含描述的变量,而是将其直接分配给描述。这样做解决了我的问题
setup(
name="Futshane_TBG",
version="1.0.0",
description=""" The description of the package """,
long_description_content_type="text/markdown",
long_description=README,
url="https://github.com/ElLoko233/Text-Based-Game-Package",
author="Lelethu Futshane",
classifiers=["License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8"],
packages=["TBG"],
include_package_data=True,
)
在上传到PyPi之前,使用Pandoc和PyPandoc将Markdown(md(文件转换为RestructedText(rst(。要完成此操作,请将以下内容添加到setup.py文件中:pip install pypandoc
try:
import pypandoc
long_description = pypandoc.convert_file('README.md', 'rst')
except(IOError, ImportError):
long_description = open('README.md').read()
setup(
name='blah',
version=find_version('blah.py'),
description='Short description',
long_description=long_description,
)