如何从 cx_Freeze 分发中排除 gitignore 文件

How to exclude gitignore files from cx_Freeze distribution

我在我的项目中包含了一些数据目录,其中 include_files 选项为 build_exe。但是,这些目录包含 .gitignore 文件,我不想将其包含在发行版中。

有没有什么方法可以使用模式来排除任何否则会被包含的文件?我查看了 cx_Freeze 文档,但 none 的选项似乎可以解决问题。

一个解决方案(根据 Thomas K) is to use glob 模块的建议,生成要包含的文件的明确列表。

from glob import glob
sql_files = glob('../sql/*/*')  # No files in ../sql/ root
doc_files = glob('../doc/*') + glob('../doc/*/*')
buildOptions = dict(include_files=list(zip(sql_files, sql_files))\
                                  + list(zip(doc_files, doc_files)))