2016-02-15 25 views
1

我遇到了用於打包此模塊的README.rst文件的問題。我查了很多帖子,但沒有發現任何幫助。long_description只包含README.rst的第一行

目前,我使用的是非常簡單的自述測試

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的所有東西嗎?
  • 我該如何解決這個問題?
  • 如何調試將來的問題?

回答

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還是有問題的設置函數。

爲了找到這個解決方案,我簡單地去了pypandoc repo和had a look at their setup.py file,這確實如此。