Search code examples
pythongitcx-freeze

How to exclude gitignore files from cx_Freeze distribution


I’m including some data directories in my project with the include_files option to build_exe. However, these directories contain .gitignore files, which I don’t want to be included in the distribution.

Is there any way to use a pattern to exclude any files that would otherwise be included? I have looked trough cx_Freeze documentation, but none of the options seem to do the trick.


Solution

  • A solution (as suggested by Thomas K) is to use glob module to generate an excplicit list of files to be included.

    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)))