Reputation: 517
I've created a cxfreeze_setup.py file and run the command python cxfreeze_setup.py build_exe
The cxfreeze_setup.py contains this:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Python 3 compatibility
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import sys
from cx_Freeze import setup, Executable
from daysgrounded.globalcfg import NAME, VERSION, DATA_FILES
from daysgrounded import (DESC, LICENSE, URL, KEYWORDS, CLASSIFIERS)
AUTHOR = 'Joao Matos'
SCRIPT = NAME + '/__main__.py'
TARGET_NAME = NAME + '.exe'
base = None
# GUI applications require a different base on Windows
if sys.platform == 'win32':
base = 'Win32GUI'
build_exe_options = dict(compressed=True,
include_files=['AUTHORS.txt',
'CHANGES.txt',
'LICENSE.txt',
'README.txt',
'README.rst',
NAME],
)
setup(name=NAME,
version=VERSION,
description=DESC,
long_description=open('README.txt').read(),
#long_description=(read('README.txt') + '\n\n' +
# read('CHANGES.txt') + '\n\n' +
# read('AUTHORS.txt')),
license=LICENSE,
url=URL,
author=AUTHOR,
author_email='[email protected]',
keywords=KEYWORDS,
classifiers=CLASSIFIERS,
executables=[Executable(script=SCRIPT,
base=base,
compress=True,
targetName=TARGET_NAME,
)],
options=dict(build_exe=build_exe_options),
)
The build works but I would like to include the *.txt files from the NAME subdirectory in the same directory where the exe is created. The include_files only allows me to include the subdirectory (not move the files).
The end result I wanted is the same that is made with a "normal" build command like python setup.py sdist bdist_egg bdist_wininst bdist_wheel where this is done with the setup.py options
include_package_data=True
package_data=dict(daysgrounded=['usage.txt', 'LICENSE.txt', 'banner.txt'])
and MANIFEST.in file with
include daysgrounded\banner.txt
include daysgrounded\LICENSE.txt
include daysgrounded\usage.txt
Thanks,
JM
Upvotes: 1
Views: 1591
Reputation: 76
If I understand correctly, you want to do the following.
BUILD_DIR/path_to_file/somefile.txt
to
DEST_DIR/somefile.txt
where dest dir also contains the {program}.exe
Try the following using the include_files like this:
include_files =
[
('path_to_file/somefile.txt', 'somefile.txt'),
('path_to_file/otherfilename.txt, 'newfilename.txt)
]
The second line demonstrates renaming the file by changing the second name.
If I understand the description above correctly, this is specific to the example:
include_files=[
('daysgrounded/AUTHORS.txt','AUTHORS.txt'),
('daysgrounded/CHANGES.txt','CHANGES.txt'),
('daysgrounded/LICENSE.txt','LICENSE.txt'),
('daysgrounded/README.txt','README.txt'),
('daysgrounded/README.rst','README.rst'),
NAME],
Upvotes: 1