views:

202

answers:

1

I'm using Python 2.6 and cx_Freeze 4.1.2 on a Windows system. I've created the setup.py to build my executable and everything works fine.

When cx_Freeze runs it movies everything to the build directory. I have some other files that i would like included in my build directory. How can i do this? Here's my structure.

src\
    setup.py
    janitor.py
    README.txt
    CHNAGELOG.txt
    helpers\
        uncompress\
            unRAR.exe
            unzip.exe

Here's my snippet:

setup

( name='Janitor',
  version='1.0',
  description='Janitor',
  author='John Doe',
  author_email='[email protected]',
  url='http://www.this-page-intentionally-left-blank.org/',
  data_files = 
      [ ('helpers\uncompress', ['helpers\uncompress\unzip.exe']),
        ('helpers\uncompress', ['helpers\uncompress\unRAR.exe']),
        ('', ['README.txt'])
      ],
  executables =
      [
      Executable\
          (
          'janitor.py', #initScript
          )
      ]
)

I can't seem to get this to work. Do i need a MANIFEST.in file?

Thank you.

+4  A: 

Figured it out.

from cx_Freeze import setup,Executable

includefiles = ['README.txt', 'CHANGELOG.txt', 'helpers\uncompress\unRAR.exe', , 'helpers\uncompress\unzip.exe']
includes = []
excludes = ['Tkinter']
packages = ['do','khh']

setup(
    name = 'myapp',
    version = '0.1',
    description = 'A general enhancement utility',
    author = 'lenin',
    author_email = '[email protected]',
    options = {'build_exe': {'excludes':excludes,'packages':packages,'include_files':includefiles}}, 
    executables = [Executable('janitor.py')]
)

Note:

  • include_files must contain "only" relative paths to the setup.py script else the build will fail
  • include_files can be a list of string i.e a bunch of files with their relative paths or
  • include_files can be a list of tuples in which the first half of the tuple is the file name with the absolute path and the second half is the destination filename with the absolute path.

(When the lack of the documentation arises, consult Kermit the Frog)

Mridang Agarwalla
Nice work. Wish I could give you several up-votes!
Craig McQueen
Thanks Craig. I tried joining the mailing list that you're on but i wasn't allowed. Could you help me out please? Is it possible to specify the destination directory? the `include_files` option simply created the same directory structure in the builds directory and dumps the included files there. Thanks.
Mridang Agarwalla
Solved this too. I went through the source. It's a pity that functions like there aren't documented well enough. I'd love to help to write some documentation for this.
Mridang Agarwalla