考虑以下封装结构:
具有以下setup.py
内容:
from setuptools import setup, find_packages
setup(
name='dfl_client',
packages=find_packages(exclude=['*tests*']),
include_package_data=True,
package_data={"": ['py.typed', '*.pyi']},
)
当我使用python setup.py sdist bdist_wheel
对其进行打包时,生成的轮子:
py.typed
文件,这很好tests
文件夹,但应根据the ^{我花了几个小时试图理解为什么,但没有成功。尤其是因为它似乎适用于其他项目
(我花了很多时间试图理解这个愚蠢的问题,我回答了自己的问题,希望能为其他面临同样问题的人节省时间)
我终于找到了罪魁祸首:它是
setuptools_scm
和include_package_data=True
标志之间的隐藏交互本身,
include_package_data=True
不会使tests
目录包含在控制盘中。但是,如果安装了setuptools_scm
,并且文件夹处于版本控制之下(并且tests
目录位于git管理的文件列表中),那么exclude
指令似乎不再被考虑因此,解决方案只是删除
include_package_data=True
,当package_data
存在时,实际上不需要删除include_package_data=True
:参见setuptools doc on including files(关于
include_package_data
,这实际上非常简单)和this related issue and workaround(解决方法似乎也适用于轮子,而不仅仅是sdist)相关问题 更多 >
编程相关推荐