【发布时间】:2016-05-04 12:05:27
【问题描述】:
我有一个模块存储库,其中包含模块代码、README.md 文件和存储在目录images/ 中的 README.md 文件中使用的图像(使用相对链接链接到 README.md 中)。为了注册模块并将其上传到 PyPI,我有文件 setup.py 和 MANIFEST.in。应该如何使图像包含并出现在 PyPI 在线文档中(如在假设页面 https://pypi.python.org/pypi/junkmodule 中出现的那样)?
我目前拥有的MANIFEST.in和setup.py(并且不包括PyPI在线文档中的图像)如下:
MANIFEST.in
include LICENSE
include README.md
include images/*
include setup.py
include junkmodule.py
setup.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import setuptools
def main():
setuptools.setup(
name = "junkmodule",
version = "0.0.0.1",
description = "provides nothing much",
long_description = Markdown_to_reStructuredText("README.md"),
url = "https://github.com/junkuser1/junkmodule",
author = "L. Ron. Hubbard",
author_email = "lrh@sern.ch",
license = "GPLv3",
py_modules = ["junkmodule"],
entry_points = """
[console_scripts]
junkmodule = junkmodule:junkmodule
"""
)
def read(*paths):
with open(os.path.join(*paths), "r") as filename:
return filename.read()
def Markdown_to_reStructuredText(filename):
try:
import pypandoc
return pypandoc.convert(filename, "rst")
except:
print("pypandoc not found; long description could be corrupted")
return read(filename)
if __name__ == "__main__":
main()
【问题讨论】: