Commits

Anthony Tuininga committed 932c82f

Added support for namespace packages.

Comments (0)

Files changed (6)

cx_Freeze/dist.py

          'comma-separated list of modules to include'),
         ('packages=', 'p',
          'comma-separated list of packages to include'),
+        ('namespace-packages=',
+         'comma-separated list of namespace packages to include'),
         ('replace-paths=', None,
          'comma-separated list of paths to replace in included modules'),
         ('path=', None,
         self.excludes = []
         self.includes = []
         self.packages = []
+        self.namespace_packages = []
         self.replace_paths = []
         self.compressed = None
         self.copy_dependent_files = None
         self._normalize("excludes")
         self._normalize("includes")
         self._normalize("packages")
+        self._normalize("namespace_packages")
         self._normalize("constants")
 
     def run(self):
                 binIncludes = self.bin_includes,
                 binExcludes = self.bin_excludes,
                 zipIncludes = self.zip_includes,
-                silent = self.silent)
+                silent = self.silent,
+                namespacePackages = self.namespace_packages)
         freezer.Freeze()
 
     def set_source_location(self, name, *pathParts):

cx_Freeze/finder.py

 import marshal
 import opcode
 import os
+import pkgutil
 import sys
 import types
 import zipfile
     def ExcludeName(self, name):
         self.excludeNames[name] = None
 
+    def ExtendPath(self):
+        self.path = pkgutil.extend_path(self.path, self.name)
+
     def IgnoreName(self, name):
         self.ignoreNames[name] = None
 

cx_Freeze/freezer.py

             appendScriptToExe = None, appendScriptToLibrary = None,
             targetDir = None, binIncludes = [], binExcludes = [],
             binPathIncludes = [], binPathExcludes = [], icon = None,
-            includeFiles = [], zipIncludes = [], silent = False):
+            includeFiles = [], zipIncludes = [], silent = False,
+            namespacePackages = []):
         self.executables = list(executables)
         self.constantsModules = list(constantsModules)
         self.includes = list(includes)
         self.excludes = list(excludes)
         self.packages = list(packages)
+        self.namespacePackages = list(namespacePackages)
         self.replacePaths = list(replacePaths)
         self.compress = compress
         self.optimizeFlag = optimizeFlag
             finder.IncludeModule(name)
         for name in argsSource.packages:
             finder.IncludePackage(name)
+        for name in argsSource.namespacePackages:
+            package = finder.IncludeModule(name)
+            package.ExtendPath()
         return finder
 
     def _PrintReport(self, fileName, modules):
             excludes = None, packages = None, replacePaths = None,
             compress = None, copyDependentFiles = None,
             appendScriptToExe = None, appendScriptToLibrary = None,
-            icon = None):
+            icon = None, namespacePackages = None):
         self.script = script
         self.initScript = initScript
         self.base = base
         self.includes = includes
         self.excludes = excludes
         self.packages = packages
+        self.namespacePackages = namespacePackages
         self.replacePaths = replacePaths
         self.compress = compress
         self.copyDependentFiles = copyDependentFiles
             self.excludes = freezer.excludes
         if self.packages is None:
             self.packages = freezer.packages
+        if self.namespacePackages is None:
+            self.namespacePackages = freezer.namespacePackages
         if self.replacePaths is None:
             self.replacePaths = freezer.replacePaths
         if self.compress is None:

cx_Freeze/hooks.py

 def load_zope(finder, module):
     """the zope package is distributed in multiple packages and they need to be
        stitched back together again."""
-    import pkgutil
-    module.path = pkgutil.extend_path(module.path, module.name)
+    module.ExtendPath()
 
 
 def load_zope_component(finder, module):

doc/cx_Freeze.html

 <td>comma separated list of packages to include, which
 includes all submodules in the package</td>
 </tr>
+<tr><td>namespace-packages</td>
+<td>comma separated list of packages to be treated as
+namespace packages (path is extended using pkgutil)</td>
+</tr>
 <tr><td>replace-paths</td>
 <td>comma separated list of paths to replace in modules
 in the form &lt;search&gt;=&lt;replace&gt;, using the value *
 <td>list of names of packages to include, including all
 of the package's submodules</td>
 </tr>
+<tr><td>namespacePackages</td>
+<td>list of packages to be treated as namespace
+packages (path is extended using pkgutil)</td>
+</tr>
 <tr><td>replacePaths</td>
 <td>list of 2-tuples containing search values and
 replacement values for paths of modules that are

doc/cx_Freeze.rst

 | packages (-p)         | comma separated list of packages to include, which  |
 |                       | includes all submodules in the package              |
 +-----------------------+-----------------------------------------------------+
+| namespace-packages    | comma separated list of packages to be treated as   |
+|                       | namespace packages (path is extended using pkgutil) |
++-----------------------+-----------------------------------------------------+
 | replace-paths         | comma separated list of paths to replace in modules |
 |                       | in the form <search>=<replace>, using the value *   |
 |                       | in the search portion of the directive will cause   |
 | packages              | list of names of packages to include, including all |
 |                       | of the package's submodules                         |
 +-----------------------+-----------------------------------------------------+
+| namespacePackages     | list of packages to be treated as namespace         |
+|                       | packages (path is extended using pkgutil)           |
++-----------------------+-----------------------------------------------------+
 | replacePaths          | list of 2-tuples containing search values and       |
 |                       | replacement values for paths of modules that are    |
 |                       | included; a search value of "*" will cause all      |
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.