【问题标题】:My RST README is not formatted correctly on PyPi我的 RST README 在 PyPi 上的格式不正确
【发布时间】:2019-08-20 16:28:30
【问题描述】:

我将一个包上传到 pypi.org,但我的 RST README 格式不正确。

这是它在 GitHub 上的样子:https://github.com/NinjaSnail1080/akinator.py

这是 PyPi 上的样子:https://pypi.org/project/akinator.py/

出于某种原因,在 GitHub 上,所有内容的格式都正确,但在 PyPi 上,它根本没有格式化。它没有显示 RST 格式的 README,而是完全乱七八糟的未格式化文本。

我尝试在我的项目上运行 python3 -m twine check dist/* 并得到了这个:

Checking distribution dist/akinator.py-1.0.3.dev3-py3-none-any.whl: warning: `long_description_content_type` missing.  defaulting to `text/x-rst`.
Failed
The project's long_description has invalid markup which will not be rendered on PyPI. The following syntax errors were detected:
line 26: Error: Unexpected indentation.
Checking distribution dist/akinator.py-1.0.3.dev3.tar.gz: warning: `long_description_content_type` missing.  defaulting to `text/x-rst`.
Failed
The project's long_description has invalid markup which will not be rendered on PyPI. The following syntax errors were detected:
line 26: Error: Unexpected indentation.
line 26: Error: Unexpected indentation.

由于某种原因,它说long_description_content_type 丢失了,这是不真实的。我的 setup.py 文件专门写了long_description_content_type="text/x-rst"。它还在long description 的第 26 行提到了意外的缩进,但该行根本没有缩进。

我完全不知道我在这里做错了什么。不知何故,它在 GitHub 上看起来非常好,但在 PyPi 上,它只是一团糟。 twine check 给我的警告没有任何意义。

【问题讨论】:

  • 尝试升级 setuptools 并重新生成发行版。

标签: python pypi python-packaging twine


【解决方案1】:

问题是您在 License 字段中是 including your entire license,但此字段是 only supposed to be a short description or name of the license -- 它不应包含换行符。

这将产生以下元数据:

Metadata-Version: 2.1
Name: akinator.py
Version: 1.0.3.dev2
Summary: An API wrapper for the online game, Akinator, written in Python
Home-page: https://github.com/NinjaSnail1080/akinator.py
Author: NinjaSnail1080
Author-email: innuganti.ashwin@gmail.com
License: MIT License

Copyright (c) 2019 NinjaSnail1080

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

第一个换行符之后的所有内容都被解释为Long-Description

要解决此问题,只需设置 license="MIT",或完全省略它 - 它是可选的,并且您已经在分类器列表中拥有它。

setuptools 中有一个突出的错误需要修复:https://github.com/pypa/setuptools/issues/1390

【讨论】:

    【解决方案2】:

    我也有同样的症状。使用 python3.7 而不是 python3.6 有帮助:

    python3.7 setup.py sdist bdist_wheel
    

    操作系统:Ubuntu 18.04.2 LTS

    【讨论】:

      猜你喜欢
      • 2013-04-28
      • 1970-01-01
      • 2018-01-12
      • 1970-01-01
      • 2014-10-15
      • 2020-10-15
      • 2018-03-27
      • 1970-01-01
      • 2020-11-04
      相关资源
      最近更新 更多