Poetry构建因node_modules存在过慢,求彻底忽略该文件夹的方案
解决Poetry构建时彻底忽略node_modules的技巧
精准配置pyproject.toml的排除规则
不要只写exclude = ["node_modules"],改用递归匹配规则确保覆盖所有子文件和目录:[tool.poetry] exclude = ["node_modules/**/*"]这种写法会让Poetry完全跳过对node_modules目录下所有内容的扫描,而非仅在打包环节排除。
用环境变量临时强制排除
构建时通过环境变量直接指定排除目录,绕过配置文件可能存在的优先级问题:POETRY_EXCLUDE="node_modules/**/*" poetry build让Poetry继承.gitignore规则
既然已在.gitignore里配置了node_modules/,可以让Poetry直接复用该规则,避免重复配置的冲突:[tool.poetry] include = ["**/*"] exclude = [] [tool.poetry.gitignore] inherit = true配置后Poetry会严格遵循.gitignore的排除逻辑,不再额外扫描已忽略的目录。
临时禁用插件构建
如果安装了Poetry插件(比如export、publish类插件),部分插件可能会额外遍历目录导致耗时增加,尝试不带插件构建:poetry build --no-plugins
内容的提问来源于stack exchange,提问作者Luke
相关产品推荐
相关产品推荐

