【问题标题】:long_description only contains first line of README.rstlong_description 仅包含 README.rst 的第一行
【发布时间】:2016-05-26 15:23:46
【问题描述】:

我对用于打包此模块的 README.rst 文件有疑问。我查了很多 SO 的帖子,但没有发现任何帮助。

目前,我正在使用一个非常简单的自述文件进行测试

pytelemetry
===========

pytelemetry enables remote monitoring and control of embedded
devices. Specifically, pytelemetry implements a custom communication
protocol, based on the PubSub messaging pattern.

这里是 setup.py 文件的概述

here = path.abspath(path.dirname(__file__))
# Get the long description from the README file
with open(path.join(here, 'README0.rst'), encoding='utf-8') as f:
    long_description = f.read()
    print(long_description) # Prints the correct readme

setup(
    name='pytelemetry',

    version='1.1.0',

    description='Lightweight remote monitoring and control of embedded devices',
    long_description=long_description, # Not working !

我使用python setup.py bdist_wheel 构建包。使用 python 3.5.1,车轮 0.24.0 和 0.29.0。 print(long_description) 工作得非常好,但是当我解压缩生成的轮子时,DESCRIPTION.rst 文件(我认为应该包含长描述)只包含:

pytelemetry

这对应于我的 README.rst 的第一行。在 pypi 上,我得到相同的输出。为什么我最后只有自述文件的第一行?

  • 我认为 DESCRIPTION.rst 包含 long_description 中 setup.py 的任何内容是否正确?
  • 我该如何解决这个问题?
  • 以后如何调试此类问题?

【问题讨论】:

    标签: python python-3.x pypi python-wheel


    【解决方案1】:

    哇,这是一个愚蠢的问题。

    失败的脚本是

    try:
        long_description = pypandoc.convert('README.md', 'rst')
    except OSError:
        print("Pandoc not found. Long_description conversion failure.")
        import io
        # pandoc is not installed, fallback to using raw contents
        with io.open('README.md', encoding="utf-8") as f:
            long_description = f.read()
    

    我添加了这一行:

    try:
        long_description = pypandoc.convert('README.md', 'rst')
        long_description = long_description.replace("\r","") # THAT $%^$*($ ONE
    except OSError:
        print("Pandoc not found. Long_description conversion failure.")
        import io
        # pandoc is not installed, fallback to using raw contents
        with io.open('README.md', encoding="utf-8") as f:
            long_description = f.read()
    

    现在,如果我解压缩生成的轮子,我可以在 DESCRIPTION.rst 中看到我的完整自述文件!耶。 我不确定是什么导致了这个问题,或者是 pypandoc 还是 setup 函数有问题。

    为了找到这个解决方案,我简单地访问了 pypandoc repo 和 had a look at their setup.py file,它正是这样做的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-26
      • 1970-01-01
      • 1970-01-01
      • 2022-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多