【发布时间】:2016-01-02 21:51:21
【问题描述】:
我一直致力于将 Python 3.5 类型提示添加到响应库中。但是当我测试发布sdist 或bdist_wheel 时,它不会安装我的.pyi 文件。我可以看到它是分发的一部分,但仅此而已。
你可以在这里看到我在我的 repo 中得到了什么:https://github.com/gaqzi/responses/tree/feature/type-hints-file
我阅读了 mentions that stub files should be distributable. 的 PEP484,但我似乎无法弄清楚如何。 :)
是否有问题是因为响应没有创建包?它只是一个单独的模块文件,这就是它没有正确添加的原因?
我在构建包时看到的内容:
% python setup.py sdist
running sdist
running egg_info
writing requirements to responses.egg-info/requires.txt
writing top-level names to responses.egg-info/top_level.txt
writing responses.egg-info/PKG-INFO
writing dependency_links to responses.egg-info/dependency_links.txt
reading manifest file 'responses.egg-info/SOURCES.txt'
writing manifest file 'responses.egg-info/SOURCES.txt'
running check
warning: check: missing meta-data: if 'author' supplied, 'author_email' must be supplied too
creating responses-0.6.0
creating responses-0.6.0/responses.egg-info
making hard links in responses-0.6.0...
hard linking README.rst -> responses-0.6.0
hard linking responses.py -> responses-0.6.0
hard linking responses.pyi -> responses-0.6.0
hard linking setup.cfg -> responses-0.6.0
hard linking setup.py -> responses-0.6.0
hard linking responses.egg-info/PKG-INFO -> responses-0.6.0/responses.egg-info
hard linking responses.egg-info/SOURCES.txt -> responses-0.6.0/responses.egg-info
hard linking responses.egg-info/dependency_links.txt -> responses-0.6.0/responses.egg-info
hard linking responses.egg-info/not-zip-safe -> responses-0.6.0/responses.egg-info
hard linking responses.egg-info/requires.txt -> responses-0.6.0/responses.egg-info
hard linking responses.egg-info/top_level.txt -> responses-0.6.0/responses.egg-info
copying setup.cfg -> responses-0.6.0
Writing responses-0.6.0/setup.cfg
Creating tar archive
removing 'responses-0.6.0' (and everything under it)
安装包后我得到了这个:
% pip install dist/responses-0.6.0.tar.gz
[...snip...]
Installing collected packages: responses
Successfully installed responses-0.6.0
% pwd
/Users/ba/.virtualenvs/responses/lib/python3.5/site-packages
% ls responses*
responses.py
responses-0.6.0.dist-info:
DESCRIPTION.rst METADATA RECORD WHEEL metadata.json top_level.txt
【问题讨论】:
-
似乎将您的
.pyi文件包含在MANIFEST.in作品中 -
假设将其添加到带有
include_package_data=True的package_data行是MANIFEST.in的可接受替代品,不,这是行不通的。参见github.com/LuminosoInsight/ordered-set/pull/42,它同时添加了ordered_set.pyi和py.typed,但是类型没有被打包。
标签: python setuptools type-hinting