mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Reworked --strip option: it will now look at _any_ file that's marked
executable in the bundle. Therefore got rid of the "binaries" attribute.
This commit is contained in:
		
							parent
							
								
									4735b234d8
								
							
						
					
					
						commit
						00a0b97dc5
					
				
					 1 changed files with 24 additions and 13 deletions
				
			
		|  | @ -363,7 +363,7 @@ class AppBuilder(BundleBuilder): | ||||||
|     # Include these packages. |     # Include these packages. | ||||||
|     includePackages = [] |     includePackages = [] | ||||||
| 
 | 
 | ||||||
|     # Strip binaries. |     # Strip binaries from debug info. | ||||||
|     strip = 0 |     strip = 0 | ||||||
| 
 | 
 | ||||||
|     # Found Python modules: [(name, codeobject, ispkg), ...] |     # Found Python modules: [(name, codeobject, ispkg), ...] | ||||||
|  | @ -373,9 +373,6 @@ class AppBuilder(BundleBuilder): | ||||||
|     missingModules = [] |     missingModules = [] | ||||||
|     maybeMissingModules = [] |     maybeMissingModules = [] | ||||||
| 
 | 
 | ||||||
|     # List of all binaries (executables or shared libs), for stripping purposes |  | ||||||
|     binaries = [] |  | ||||||
| 
 |  | ||||||
|     def setup(self): |     def setup(self): | ||||||
|         if self.standalone and self.mainprogram is None: |         if self.standalone and self.mainprogram is None: | ||||||
|             raise BundleBuilderError, ("must specify 'mainprogram' when " |             raise BundleBuilderError, ("must specify 'mainprogram' when " | ||||||
|  | @ -425,7 +422,6 @@ def preProcess(self): | ||||||
|             execpath = pathjoin(self.execdir, execname) |             execpath = pathjoin(self.execdir, execname) | ||||||
|             if not self.symlink_exec: |             if not self.symlink_exec: | ||||||
|                 self.files.append((self.executable, execpath)) |                 self.files.append((self.executable, execpath)) | ||||||
|                 self.binaries.append(execpath) |  | ||||||
|             self.execpath = execpath |             self.execpath = execpath | ||||||
| 
 | 
 | ||||||
|         if self.mainprogram is not None: |         if self.mainprogram is not None: | ||||||
|  | @ -502,8 +498,6 @@ def addPythonFramework(self): | ||||||
|         for item in PYTHONFRAMEWORKGOODIES: |         for item in PYTHONFRAMEWORKGOODIES: | ||||||
|             src = pathjoin(frameworkpath, item) |             src = pathjoin(frameworkpath, item) | ||||||
|             dst = pathjoin(destbase, item) |             dst = pathjoin(destbase, item) | ||||||
|             if item == "Python": |  | ||||||
|                 self.binaries.append(dst) |  | ||||||
|             self.files.append((src, dst)) |             self.files.append((src, dst)) | ||||||
| 
 | 
 | ||||||
|     def addPythonModules(self): |     def addPythonModules(self): | ||||||
|  | @ -546,12 +540,30 @@ def stripBinaries(self): | ||||||
|             self.message("Error: can't strip binaries: no strip program at " |             self.message("Error: can't strip binaries: no strip program at " | ||||||
|                 "%s" % STRIP_EXEC, 0) |                 "%s" % STRIP_EXEC, 0) | ||||||
|         else: |         else: | ||||||
|  |             import stat | ||||||
|             self.message("Stripping binaries", 1) |             self.message("Stripping binaries", 1) | ||||||
|             for relpath in self.binaries: |             def walk(top): | ||||||
|                 self.message("Stripping %s" % relpath, 2) |                 for name in os.listdir(top): | ||||||
|                 abspath = pathjoin(self.bundlepath, relpath) |                     path = pathjoin(top, name) | ||||||
|                 if not os.path.islink(abspath): |                     if os.path.islink(path): | ||||||
|                     rv = os.system("%s -S \"%s\"" % (STRIP_EXEC, abspath)) |                         continue | ||||||
|  |                     if os.path.isdir(path): | ||||||
|  |                         walk(path) | ||||||
|  |                     else: | ||||||
|  |                         mod = os.stat(path)[stat.ST_MODE] | ||||||
|  |                         if not (mod & 0100): | ||||||
|  |                             continue | ||||||
|  |                         relpath = path[len(self.bundlepath):] | ||||||
|  |                         self.message("Stripping %s" % relpath, 2) | ||||||
|  |                         inf, outf = os.popen4("%s -S \"%s\"" % | ||||||
|  |                                               (STRIP_EXEC, path)) | ||||||
|  |                         output = outf.read().strip() | ||||||
|  |                         if output: | ||||||
|  |                             # usually not a real problem, like when we're | ||||||
|  |                             # trying to strip a script | ||||||
|  |                             self.message("Problem stripping %s:" % relpath, 3) | ||||||
|  |                             self.message(output, 3) | ||||||
|  |             walk(self.bundlepath) | ||||||
| 
 | 
 | ||||||
|     def findDependencies(self): |     def findDependencies(self): | ||||||
|         self.message("Finding module dependencies", 1) |         self.message("Finding module dependencies", 1) | ||||||
|  | @ -598,7 +610,6 @@ def findDependencies(self): | ||||||
|                     dstpath = name.split(".")[:-1] + [filename] |                     dstpath = name.split(".")[:-1] + [filename] | ||||||
|                     dstpath = pathjoin("Contents", "Resources", *dstpath) |                     dstpath = pathjoin("Contents", "Resources", *dstpath) | ||||||
|                 self.files.append((path, dstpath)) |                 self.files.append((path, dstpath)) | ||||||
|                 self.binaries.append(dstpath) |  | ||||||
|             if mod.__code__ is not None: |             if mod.__code__ is not None: | ||||||
|                 ispkg = mod.__path__ is not None |                 ispkg = mod.__path__ is not None | ||||||
|                 if not USE_ZIPIMPORT or name != "site": |                 if not USE_ZIPIMPORT or name != "site": | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Just van Rossum
						Just van Rossum