微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何将图像添加到Python包索引文档?

我有一个模块存储库,其中包含模块代码,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()

解决方法

A possible solution将在GitHub上托管图像,并从那里获取README中的图像.我亲自在 commit,this result进行了测试.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐