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 moves 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='john.doe@gmail.com', 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?
There's a more complex example at: cx_freeze - wxPyWiki
The lacking documentation of all the options is at: cx_Freeze (Internet Archive)
With
cx_Freeze
, I still get a build output of 11 files in a single folder, though, unlike withPy2Exe
.Alternatives: Packaging | The Mouse Vs. Python
In order to find your attached files (
include_files = [-> your attached files <-]
) you should insert the following function in your setup.py code:See cx-freeze: using data files
Figured it out.
Note:
include_files
must contain "only" relative paths to thesetup.py
script else the build will fail.include_files
can be a list of string i.e a bunch of files with their relative pathsor
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)
Also you can create separate script that will copy files after the build. It's what I use to rebuild the app on windows (you should have "GNU utilities for win32" installed to make "cp" works).
build.bat: