Commits

Anthony Tuininga committed bed25f1

Readded support for the zip include option. Thanks to Baptiste for the initial
patch.

Comments (0)

Files changed (5)

cx_Freeze/dist.py

          'comma-separated list of constants to include'),
         ('include-files=', 'f',
          'list of tuples of additional files to include in distribution'),
+        ('zip-includes=', None,
+         'list of tuples of additional files to include in zip file'),
         ('bin-includes', None,
          'list of names of files to include when determining dependencies'),
         ('bin-excludes', None,
         self.icon = None
         self.constants = []
         self.include_files = []
+        self.zip_includes = []
         self.bin_excludes = []
         self.bin_includes = []
         self.silent = None
                 includeFiles = self.include_files,
                 binIncludes = self.bin_includes,
                 binExcludes = self.bin_excludes,
+                zipIncludes = self.zip_includes,
                 silent = self.silent)
         freezer.Freeze()
 

cx_Freeze/freezer.py

             appendScriptToExe = None, appendScriptToLibrary = None,
             targetDir = None, binIncludes = [], binExcludes = [],
             binPathIncludes = [], binPathExcludes = [], icon = None,
-            includeFiles = [], silent = False):
-        self.executables = executables
-        self.constantsModules = constantsModules
-        self.includes = includes
-        self.excludes = excludes
-        self.packages = packages
-        self.replacePaths = replacePaths
+            includeFiles = [], zipIncludes = [], silent = False):
+        self.executables = list(executables)
+        self.constantsModules = list(constantsModules)
+        self.includes = list(includes)
+        self.excludes = list(excludes)
+        self.packages = list(packages)
+        self.replacePaths = list(replacePaths)
         self.compress = compress
         self.optimizeFlag = optimizeFlag
         self.copyDependentFiles = copyDependentFiles
                 for n in self._GetDefaultBinPathExcludes() + binPathExcludes]
         self.icon = icon
         self.includeFiles = list(includeFiles)
+        self.includeFiles = self._ProcessPathSpecs(includeFiles)
+        self.zipIncludes = self._ProcessPathSpecs(zipIncludes)
         self.silent = silent
         self._VerifyConfiguration()
 
             sys.stdout.write(" %-25s %s\n" % (module.name, module.file or ""))
         sys.stdout.write("\n")
 
+    def _ProcessPathSpecs(self, specs):
+        processedSpecs = []
+        for spec in specs:
+            if not isinstance(spec, (list, tuple)):
+                processedSpecs.append((spec, spec))
+            elif len(spec) != 2:
+                raise ConfigError("path spec must be a list or tuple of "
+                        "length two")
+            else:
+                processedSpecs.append(spec)
+        return processedSpecs
+
     def _RemoveFile(self, path):
         if os.path.exists(path):
             os.chmod(path, stat.S_IWRITE)
             self.path = sys.path
         if self.appendScriptToLibrary:
             self._VerifyCanAppendToLibrary()
-        for sourceFileName, targetFileName in self.includeFiles:
+        for sourceFileName, targetFileName in self.includeFiles + self.zipIncludes:
             if not os.path.exists(sourceFileName):
                 raise ConfigError("cannot find file/directory named %s",
                         sourceFileName)
             if compress:
                 zinfo.compress_type = zipfile.ZIP_DEFLATED
             outFile.writestr(zinfo, data)
+
+        for sourceFileName, targetFileName in self.zipIncludes:
+            outFile.write(sourceFileName, targetFileName)
+
         outFile.close()
+
         origPath = os.environ["PATH"]
         for module, target in filesToCopy:
             try:

cx_Freeze/main.py

         sys.path = paths + sys.path
     if options.script is not None:
         sys.path.insert(0, os.path.dirname(options.script))
+    zipIncludes = []
+    if options.zipIncludes:
+        for spec in options.zipIncludes:
+            if '=' in spec:
+                zipIncludes.append(spec.split('=', 1))
+            else:
+                zipIncludes.append(spec)
+    options.zipIncludes = zipIncludes
     return options
 
 
             createLibraryZip = False,
             appendScriptToExe = True,
             targetDir = options.targetDir,
+            zipIncludes = options.zipIncludes,
             icon = options.icon,
             silent = options.silent)
     freezer.Freeze()

doc/cx_Freeze.html

 <tr><td>include-files</td>
 <td>list containing files to be copied to the target
 directory; it is expected that this list will
-contain 2-tuples for the source and destination;
-the source can be a file or a directory (in which
-case the tree is copied except for .svn and CVS
-directories); the target must not be an absolute
-path</td>
+contain strings or 2-tuples for the source and
+destination; the source can be a file or a directory
+(in which case the tree is copied except for .svn
+and CVS directories); the target must not be an
+absolute path</td>
+</tr>
+<tr><td>zip-includes</td>
+<td>list containing files to be included in the zip file
+directory; it is expected that this list will
+contain strings or 2-tuples for the source and
+destination</td>
 </tr>
 <tr><td>bin-includes</td>
 <td>list of names of files to include when determining

doc/cx_Freeze.rst

 +-----------------------+-----------------------------------------------------+
 | include-files         | list containing files to be copied to the target    |
 |                       | directory; it is expected that this list will       |
-|                       | contain 2-tuples for the source and destination;    |
-|                       | the source can be a file or a directory (in which   |
-|                       | case the tree is copied except for .svn and CVS     |
-|                       | directories); the target must not be an absolute    |
-|                       | path                                                |
+|                       | contain strings or 2-tuples for the source and      |
+|                       | destination; the source can be a file or a directory|
+|                       | (in which case the tree is copied except for .svn   |
+|                       | and CVS directories); the target must not be an     |
+|                       | absolute path                                       |
++-----------------------+-----------------------------------------------------+
+| zip-includes          | list containing files to be included in the zip file|
+|                       | directory; it is expected that this list will       |
+|                       | contain strings or 2-tuples for the source and      |
+|                       | destination                                         |
 +-----------------------+-----------------------------------------------------+
 | bin-includes          | list of names of files to include when determining  |
 |                       | dependencies of binary files that would normally be |