mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	Some far-reaching naming changes:
* Command method 'find_peer()' -> 'get_finalized_command()' * Command method 'run_peer()' -> 'run_command()' Also deleted the 'get_command_option()' method from Command, and fixed the one place where it was used (in "bdist_dumb").
This commit is contained in:
		
							parent
							
								
									25bfd0e8d0
								
							
						
					
					
						commit
						4fb29e55f8
					
				
					 11 changed files with 59 additions and 78 deletions
				
			
		|  | @ -53,7 +53,7 @@ def finalize_options (self): | |||
|         # temporary directories (eg. we'll probably have | ||||
|         # "build/bdist.<plat>/dumb", "build/bdist.<plat>/rpm", etc.) | ||||
|         if self.bdist_base is None: | ||||
|             build_base = self.find_peer('build').build_base | ||||
|             build_base = self.get_finalized_command('build').build_base | ||||
|             plat = get_platform() | ||||
|             self.bdist_base = os.path.join (build_base, 'bdist.' + plat) | ||||
| 
 | ||||
|  | @ -79,9 +79,9 @@ def run (self): | |||
|                   "invalid archive format '%s'" % self.format | ||||
| 
 | ||||
|         if cmd_name not in self.no_format_option: | ||||
|             sub_cmd = self.find_peer (cmd_name) | ||||
|             sub_cmd = self.get_finalized_command (cmd_name) | ||||
|             sub_cmd.format = self.format | ||||
|         self.run_peer (cmd_name) | ||||
|         self.run_command (cmd_name) | ||||
| 
 | ||||
|     # run() | ||||
| 
 | ||||
|  |  | |||
|  | @ -40,7 +40,7 @@ def initialize_options (self): | |||
| 
 | ||||
|     def finalize_options (self): | ||||
|         if self.bdist_dir is None: | ||||
|             bdist_base = self.get_peer_option('bdist', 'bdist_base') | ||||
|             bdist_base = self.get_finalized_command('bdist').bdist_base | ||||
|             self.bdist_dir = os.path.join(bdist_base, 'dumb') | ||||
| 
 | ||||
|         if self.format is None: | ||||
|  | @ -56,10 +56,10 @@ def finalize_options (self): | |||
| 
 | ||||
|     def run (self): | ||||
| 
 | ||||
|         self.run_peer ('build') | ||||
|         self.run_command ('build') | ||||
| 
 | ||||
|         # XXX don't use 'self.find_peer()', because it always runs | ||||
|         # 'ensure_ready()' on the command object; we explictly want a | ||||
|         # XXX don't use 'self.get_finalized_command()', because it always runs | ||||
|         # 'ensure_finalized()' on the command object; we explictly want a | ||||
|         # command object that has *not* been finalized, so we can set | ||||
|         # options on it!  (The option we set, 'root', is so that we can do | ||||
|         # a proper "fake install" using this install command object.) | ||||
|  | @ -67,7 +67,7 @@ def run (self): | |||
|         install.root = self.bdist_dir | ||||
| 
 | ||||
|         self.announce ("installing to %s" % self.bdist_dir) | ||||
|         install.ensure_ready() | ||||
|         install.ensure_finalized() | ||||
|         install.run() | ||||
| 
 | ||||
|         # And make an archive relative to the root of the | ||||
|  |  | |||
|  | @ -1,20 +1,17 @@ | |||
| """distutils.command.bdist_rpm | ||||
| 
 | ||||
| Implements the Distutils 'bdist_rpm' command (create RPM source and binary | ||||
| distributions.""" | ||||
| distributions).""" | ||||
| 
 | ||||
| # created 2000/04/25, by Harry Henry Gebel | ||||
| 
 | ||||
| __revision__ = "$Id$" | ||||
| 
 | ||||
| from os.path import exists, basename | ||||
| import os | ||||
| import os, string | ||||
| from types import * | ||||
| from distutils.core import Command | ||||
| from distutils.util import mkpath, write_file, copy_file | ||||
| from distutils.errors import * | ||||
| from string import join, lower | ||||
| from types import StringType, DictType, LongType, FloatType, IntType, \ | ||||
|      ListType, TupleType | ||||
| 
 | ||||
| class bdist_rpm (Command): | ||||
| 
 | ||||
|  | @ -68,23 +65,15 @@ def run (self): | |||
| 
 | ||||
|         # make directories | ||||
|         if self.spec_only: | ||||
|             self.execute(mkpath, ('redhat',), "Created './redhat' directory") | ||||
|             self.mkpath('redhat') | ||||
|         else: | ||||
|             self.execute(mkpath, ('build/rpm/SOURCES',), | ||||
|                          "Created RPM source directory") | ||||
|             self.execute(mkpath, ('build/rpm/SPECS',), | ||||
|                          "Created RPM source directory") | ||||
|             self.execute(mkpath, ('build/rpm/BUILD',), | ||||
|                          "Created RPM source directory") | ||||
|             self.execute(mkpath, ('build/rpm/RPMS',), | ||||
|                          "Created RPM source directory") | ||||
|             self.execute(mkpath, ('build/rpm/SRPMS',), | ||||
|                          "Created RPM source directory") | ||||
|             for d in ('SOURCES', 'SPECS', 'BUILD', 'RPMS', 'SRPMS'): | ||||
|                 self.mkpath(os.path.join('build/rpm', d)) | ||||
| 
 | ||||
|         # spec file goes into .redhat directory if '--spec-only specified', | ||||
|         # into build/rpm/spec otherwisu | ||||
|         # into build/rpm/spec otherwise | ||||
|         if self.spec_only: | ||||
|             spec_path = './redhat/%s.spec' % self.distribution.get_name() | ||||
|             spec_path = 'redhat/%s.spec' % self.distribution.get_name() | ||||
|         else: | ||||
|             spec_path = ('build/rpm/SPECS/%s.spec' % | ||||
|                          self.distribution.get_name()) | ||||
|  | @ -98,12 +87,12 @@ def run (self): | |||
| 
 | ||||
|         # make a source distribution and copy to SOURCES directory with | ||||
|         # optional icon | ||||
|         sdist = self.find_peer ('sdist') | ||||
|         sdist = self.get_finalized_command ('sdist') | ||||
|         if self.use_bzip2: | ||||
|             sdist.formats = ['bztar'] | ||||
|         else: | ||||
|             sdist.formats = ['gztar'] | ||||
|         self.run_peer('sdist') | ||||
|         self.run_command('sdist') | ||||
|         if self.use_bzip2: | ||||
|             source = self.distribution.get_fullname() + '.tar.bz2' | ||||
|         else: | ||||
|  | @ -111,7 +100,7 @@ def run (self): | |||
|         self.execute(copy_file, (source, 'build/rpm/SOURCES'), | ||||
|                      'Copying source distribution to SOURCES') | ||||
|         if self.icon: | ||||
|             if exists(self.icon): | ||||
|             if os.path.exists(self.icon): | ||||
|                 self.execute(copy_file, (self.icon, 'build/rpm/SOURCES'), | ||||
|                      'Copying icon to SOURCES') | ||||
|             else: | ||||
|  | @ -144,10 +133,12 @@ def _get_package_data(self): | |||
|         DistributionMetadata class, then from the package_data file, which is | ||||
|         Python code read with execfile() ''' | ||||
| 
 | ||||
|         from string import join | ||||
| 
 | ||||
|         package_type = 'rpm' | ||||
|          | ||||
|         # read in package data, if any | ||||
|         if exists('package_data'): | ||||
|         if os.path.exists('package_data'): | ||||
|             try: | ||||
|                 exec(open('package_data')) | ||||
|             except: | ||||
|  | @ -195,7 +186,7 @@ def _get_package_data(self): | |||
|         self.doc = self._check_string_list('doc') | ||||
|         if type(self.doc) == ListType: | ||||
|             for readme in ('README', 'README.txt'): | ||||
|                 if exists(readme) and readme not in self.doc: | ||||
|                 if os.path.exists(readme) and readme not in self.doc: | ||||
|                     self.doc.append(readme) | ||||
|             self.doc = join(self.doc) | ||||
|         self.provides = join(self._check_string_list('provides')) | ||||
|  | @ -246,9 +237,9 @@ def _make_spec_file(self): | |||
|                       'Conflicts', | ||||
|                       'Obsoletes', | ||||
|                       ): | ||||
|             if getattr(self, lower(field)): | ||||
|                 spec_file.append('%s: %s' % (field, getattr(self, | ||||
|                                                             lower(field)))) | ||||
|             if getattr(self, string.lower(field)): | ||||
|                 spec_file.append('%s: %s' % | ||||
|                                  (field, getattr(self, string.lower(field)))) | ||||
|                        | ||||
|         if self.distribution.get_url() != 'UNKNOWN': | ||||
|             spec_file.append('Url: ' + self.distribution.get_url()) | ||||
|  | @ -260,7 +251,7 @@ def _make_spec_file(self): | |||
|              spec_file.append('BuildRequires: ' + self.build_requires) | ||||
| 
 | ||||
|         if self.icon: | ||||
|             spec_file.append('Icon: ' + basename(self.icon)) | ||||
|             spec_file.append('Icon: ' + os.path.basename(self.icon)) | ||||
| 
 | ||||
|         spec_file.extend([ | ||||
|             '', | ||||
|  | @ -388,5 +379,3 @@ def _check_string_list(self, var_name, default_value = []): | |||
|                    'list or tuple of strings' % var_name) | ||||
|         else: | ||||
|             return default_value | ||||
| 
 | ||||
| # class bdist_rpm | ||||
|  |  | |||
|  | @ -92,20 +92,20 @@ def run (self): | |||
|         # Invoke the 'build_py' command to "build" pure Python modules | ||||
|         # (ie. copy 'em into the build tree) | ||||
|         if self.distribution.has_pure_modules(): | ||||
|             self.run_peer ('build_py') | ||||
|             self.run_command ('build_py') | ||||
| 
 | ||||
|         # Build any standalone C libraries next -- they're most likely to | ||||
|         # be needed by extension modules, so obviously have to be done | ||||
|         # first! | ||||
|         if self.distribution.has_c_libraries(): | ||||
|             self.run_peer ('build_clib') | ||||
|             self.run_command ('build_clib') | ||||
| 
 | ||||
|         # And now 'build_ext' -- compile extension modules and put them | ||||
|         # into the build tree | ||||
|         if self.distribution.has_ext_modules(): | ||||
|             self.run_peer ('build_ext') | ||||
|             self.run_command ('build_ext') | ||||
| 
 | ||||
|         if self.distribution.has_scripts(): | ||||
|             self.run_peer ('build_scripts') | ||||
|             self.run_command ('build_scripts') | ||||
| 
 | ||||
| # class build | ||||
|  |  | |||
|  | @ -167,7 +167,7 @@ def run (self): | |||
|         # directory where we put them is in the library search path for | ||||
|         # linking extensions. | ||||
|         if self.distribution.has_c_libraries(): | ||||
|             build_clib = self.find_peer ('build_clib') | ||||
|             build_clib = self.get_finalized_command ('build_clib') | ||||
|             self.libraries.extend (build_clib.get_library_names() or []) | ||||
|             self.library_dirs.append (build_clib.build_clib) | ||||
| 
 | ||||
|  | @ -294,7 +294,7 @@ def build_extensions (self): | |||
|                 package = string.join (modpath[0:-1], '.') | ||||
|                 base = modpath[-1] | ||||
| 
 | ||||
|                 build_py = self.find_peer ('build_py') | ||||
|                 build_py = self.get_finalized_command ('build_py') | ||||
|                 package_dir = build_py.get_package_dir (package) | ||||
|                 ext_filename = os.path.join (package_dir, | ||||
|                                              self.get_ext_filename(base)) | ||||
|  |  | |||
|  | @ -454,11 +454,11 @@ def run (self): | |||
| 
 | ||||
|         # Obviously have to build before we can install | ||||
|         if not self.skip_build: | ||||
|             self.run_peer ('build') | ||||
|             self.run_command ('build') | ||||
| 
 | ||||
|         # Run all sub-commands (at least those that need to be run) | ||||
|         for cmd_name in self.get_sub_commands(): | ||||
|             self.run_peer (cmd_name) | ||||
|             self.run_command (cmd_name) | ||||
| 
 | ||||
|         if self.path_file: | ||||
|             self.create_path_file () | ||||
|  | @ -507,7 +507,7 @@ def get_outputs (self): | |||
|         # get the outputs of all its sub-commands. | ||||
|         outputs = [] | ||||
|         for cmd_name in self.get_sub_commands(): | ||||
|             cmd = self.find_peer (cmd_name) | ||||
|             cmd = self.get_finalized_command (cmd_name) | ||||
|             outputs.extend (cmd.get_outputs()) | ||||
| 
 | ||||
|         return outputs | ||||
|  | @ -517,7 +517,7 @@ def get_inputs (self): | |||
|         # XXX gee, this looks familiar ;-( | ||||
|         inputs = [] | ||||
|         for cmd_name in self.get_sub_commands(): | ||||
|             cmd = self.find_peer (cmd_name) | ||||
|             cmd = self.get_finalized_command (cmd_name) | ||||
|             inputs.extend (cmd.get_inputs()) | ||||
| 
 | ||||
|         return inputs | ||||
|  |  | |||
|  | @ -46,9 +46,9 @@ def run (self): | |||
|         # Make sure we have built everything we need first | ||||
|         if not self.skip_build: | ||||
|             if self.distribution.has_pure_modules(): | ||||
|                 self.run_peer ('build_py') | ||||
|                 self.run_command ('build_py') | ||||
|             if self.distribution.has_ext_modules(): | ||||
|                 self.run_peer ('build_ext') | ||||
|                 self.run_command ('build_ext') | ||||
| 
 | ||||
|         # Install everything: simply dump the entire contents of the build | ||||
|         # directory to the installation directory (that's the beauty of | ||||
|  | @ -85,7 +85,7 @@ def _mutate_outputs (self, has_any, build_cmd, cmd_option, output_dir): | |||
|         if not has_any: | ||||
|             return [] | ||||
| 
 | ||||
|         build_cmd = self.find_peer (build_cmd) | ||||
|         build_cmd = self.get_finalized_command (build_cmd) | ||||
|         build_files = build_cmd.get_outputs() | ||||
|         build_dir = getattr (build_cmd, cmd_option) | ||||
| 
 | ||||
|  | @ -138,11 +138,11 @@ def get_inputs (self): | |||
|         inputs = [] | ||||
|          | ||||
|         if self.distribution.has_pure_modules(): | ||||
|             build_py = self.find_peer ('build_py') | ||||
|             build_py = self.get_finalized_command ('build_py') | ||||
|             inputs.extend (build_py.get_outputs()) | ||||
| 
 | ||||
|         if self.distribution.has_ext_modules(): | ||||
|             build_ext = self.find_peer ('build_ext') | ||||
|             build_ext = self.get_finalized_command ('build_ext') | ||||
|             inputs.extend (build_ext.get_outputs()) | ||||
| 
 | ||||
|         return inputs | ||||
|  |  | |||
|  | @ -35,7 +35,7 @@ def finalize_options (self): | |||
| 
 | ||||
|     def run (self): | ||||
|         if not self.skip_build: | ||||
|             self.run_peer('build_scripts') | ||||
|             self.run_command('build_scripts') | ||||
|         self.outfiles = self.copy_tree (self.build_dir, self.install_dir) | ||||
|         if os.name == 'posix': | ||||
|             # Set the executable bits (owner, group, and world) on | ||||
|  |  | |||
|  | @ -223,15 +223,15 @@ def find_defaults (self): | |||
|                 self.files.extend (files) | ||||
| 
 | ||||
|         if self.distribution.has_pure_modules(): | ||||
|             build_py = self.find_peer ('build_py') | ||||
|             build_py = self.get_finalized_command ('build_py') | ||||
|             self.files.extend (build_py.get_source_files ()) | ||||
| 
 | ||||
|         if self.distribution.has_ext_modules(): | ||||
|             build_ext = self.find_peer ('build_ext') | ||||
|             build_ext = self.get_finalized_command ('build_ext') | ||||
|             self.files.extend (build_ext.get_source_files ()) | ||||
| 
 | ||||
|         if self.distribution.has_c_libraries(): | ||||
|             build_clib = self.find_peer ('build_clib') | ||||
|             build_clib = self.get_finalized_command ('build_clib') | ||||
|             self.files.extend (build_clib.get_source_files ()) | ||||
| 
 | ||||
| 
 | ||||
|  | @ -441,7 +441,7 @@ def read_template (self): | |||
|         # while loop over lines of template file | ||||
| 
 | ||||
|         # Prune away the build and source distribution directories | ||||
|         build = self.find_peer ('build') | ||||
|         build = self.get_finalized_command ('build') | ||||
|         exclude_pattern (self.files, None, prefix=build.build_base) | ||||
| 
 | ||||
|         base_dir = self.distribution.get_fullname() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Greg Ward
						Greg Ward