title: How can I appropriately include external resources with cxfreeze?
body: <p>I'm trying to use <a href="https://cx_freeze.readthedocs.org/en/latest/distutils.html#distutils" rel="nofollow">cxfreeze</a> to build my Python scripts into an <code>.exe</code> file.  However my scripts use some external data files which aren't being packaged into the <code>libary.zip</code> file created.</p>
  
  <p>For example, my scripts are located in <code>src/</code>, and the external data is located in <code>src/data/</code>.  I've specified the <code>include_files</code> property in the <code>build_exe_options</code>, but this only <em>copies</em> the directory and files into the built directory; it doesn't add them to <code>library.zip</code>, which is where the scripts end up looking for the files.</p>
  
  <p>Even if I go in to the created <code>library.zip</code> and manually add the <code>data</code> directory, I receive the same error.  Any idea how to get <code>cxfreeze</code> to package these external resources appropriately?</p>
  
  <p><strong>setup.py</strong></p>
  
  <pre><code>from cx_Freeze import setup, Executable
  
  build_exe_options = {"includes" : ["re"], "include_files" : ["data/table_1.txt", "data/table_2.txt"]}
  
  setup(name = "My Script",
        version = "0.8",
        description = "My Script",
        options = { "build_exe" : build_exe_options },
        executables = [Executable("my_script.py")])
  </code></pre>
  
  <p><strong>fileutil.py</strong> (where it tries to read the resource files)</p>
  
  <pre><code>def read_file(filename):
      path, fl = os.path.split(os.path.realpath(__file__))
      filename = os.path.join(path, filename)
      with open(filename, "r") as file:
          lines = [line.strip() for line in file]
          return [line for line in lines if len(line) == 0 or line[0] != "#"]
  </code></pre>
  
  <p>... called with ...</p>
  
  <pre><code>read_file("data/table_1.txt")
  </code></pre>
  
  <p><strong>Error Traceback</strong></p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Python33\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 2
  7, in &lt;module&gt; exec(code, m.__dict__)
    File "my_script.py", line 94, in &lt;module&gt;
    File "my_script.py", line 68, in run
    File "C:\workspaces\py\test_script\src\tables.py", line 12, in load_data
      raw_gems = read_file("data/table_1.txt")
    File "C:\workspaces\py\test_script\src\fileutil.py", line 8, in read_file
      with open(filename, "r") as file:
  FileNotFoundError: [Errno 2] No such file or directory:
  'C:\\workspaces\\py\\test_script\\src\\build\\exe.win32-3.3\\library.zip\\data/table_1.txt'
  </code></pre>