Python 如何将类型提示分发给PyPi?
我一直致力于将Python 3.5类型提示添加到响应库中。但当我测试制作发行版时,Python 如何将类型提示分发给PyPi?,python,setuptools,type-hinting,Python,Setuptools,Type Hinting,我一直致力于将Python 3.5类型提示添加到响应库中。但当我测试制作发行版时,sdist或bdist\u wheel,它不会安装我的.pyi文件。我可以看到它是发行版的一部分,但它并没有超出这个范围 你可以在这里看到我的回购协议: 我读了PEP484,但我似乎不知道怎么读。:) 是否因为响应不创建包而存在问题?它只是一个模块文件,这就是为什么不能正确添加它的原因 构建包时看到的内容: % python setup.py sdist running sdist running egg_info
sdist
或bdist\u wheel
,它不会安装我的.pyi
文件。我可以看到它是发行版的一部分,但它并没有超出这个范围
你可以在这里看到我的回购协议:
我读了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
根据,您应该将package_data={“my_package”:[“py.typed”,“foo.pyi”]}
作为参数传递给setup.py
中的setup
。请注意,“foo.pyi”
是从要分发到
存根文件()
我已经创建了一个示例repo,您可以在那里进行测试。似乎将您的
.pyi
文件包含在清单中。在
工作中,假设使用include\u package\u data=True将其添加到包数据
行是清单的可接受替代品。在
中,不,这不起作用。请参阅,它同时添加了ordered_set.pyi
和py.typed
,但这些类型没有打包。您还可以全局处理所有.pyi文件:[“py.typed”、“*.pyi”、“***/*.pyi”]
。