gpt4 book ai didi

python - setuptools 上传 python 包

转载 作者:太空宇宙 更新时间:2023-11-04 10:41:47 25 4
gpt4 key购买 nike

我正在关注 setuptools tutorial并且,在解决了几个问题之后,我想出了最终的自述文件问题 - 我在项目中创建了一个 README.rst 文件 ( hosted on github ) 并在 setup.py 文件中使用它,就像教程说的那样:

import os
from setuptools import setup

def read(fname):
return open(os.path.join(os.path.dirname(os.path.abspath(__file__)), fname)).read()

setup(
...
long_description = read('README.rst'),
...
)

我已成功上传我的 registered python package我尝试使用 pip 在本地安装它 - 这就是问题发生的地方:

$ sudo pip install nac
Downloading/unpacking nac
Downloading nac-0.1.0.tar.gz
Running setup.py egg_info for package nac
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/home/tomasz/build/nac/setup.py", line 22, in <module>
long_description = read('README.rst'),
File "/home/tomasz/build/nac/setup.py", line 5, in read
return open(os.path.join(os.path.dirname(os.path.abspath(__file__)), fname)).read()
IOError: [Errno 2] No such file or directory: '/home/tomasz/build/nac/README.rst'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "<string>", line 14, in <module>

File "/home/tomasz/build/nac/setup.py", line 22, in <module>

long_description = read('README.rst'),

File "/home/tomasz/build/nac/setup.py", line 5, in read

return open(os.path.join(os.path.dirname(os.path.abspath(__file__)), fname)).read()

IOError: [Errno 2] No such file or directory: '/home/tomasz/build/nac/README.rst'

我知道这个错误的原因是什么:安装程序已经下载了软件包并尝试运行 setup.py,但它找不到 .rst 文件并最终停止。

我想要一个 github 的顶级文档(它自动显示在 repo 主页上)并且顶级文档文件不属于任何 python 模块(不包含在 pip 包中)。无论如何,我无法想出一个聪明的解决方案来克服这个问题。这就是冲突……欢迎任何想法。

最佳答案

我在 Python Package Distrubition tutorial 中找到了合适的信息根据它,我只需要添加具有以下内容的 MANIFEST.in 文件:

include *.rst

仅此而已。

关于python - setuptools 上传 python 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20177576/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com