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").
diff --git a/Lib/distutils/command/bdist.py b/Lib/distutils/command/bdist.py
index 892712e..df4e3a0 100644
--- a/Lib/distutils/command/bdist.py
+++ b/Lib/distutils/command/bdist.py
@@ -53,7 +53,7 @@
# 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 @@
"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()
diff --git a/Lib/distutils/command/bdist_dumb.py b/Lib/distutils/command/bdist_dumb.py
index eaa1927..51e35e4 100644
--- a/Lib/distutils/command/bdist_dumb.py
+++ b/Lib/distutils/command/bdist_dumb.py
@@ -40,7 +40,7 @@
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 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 @@
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
diff --git a/Lib/distutils/command/bdist_rpm.py b/Lib/distutils/command/bdist_rpm.py
index d10d076..d07f924 100644
--- a/Lib/distutils/command/bdist_rpm.py
+++ b/Lib/distutils/command/bdist_rpm.py
@@ -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 @@
# 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 @@
# 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 @@
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 @@
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 @@
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 @@
'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 @@
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 @@
'list or tuple of strings' % var_name)
else:
return default_value
-
-# class bdist_rpm
diff --git a/Lib/distutils/command/build.py b/Lib/distutils/command/build.py
index d9eed76..b0894b8 100644
--- a/Lib/distutils/command/build.py
+++ b/Lib/distutils/command/build.py
@@ -92,20 +92,20 @@
# 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
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
index acf1d7b..cef3ca8 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -167,7 +167,7 @@
# 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 @@
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))
diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
index d89ce4d..bc5d8f3 100644
--- a/Lib/distutils/command/install.py
+++ b/Lib/distutils/command/install.py
@@ -454,11 +454,11 @@
# 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 @@
# 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 @@
# 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
diff --git a/Lib/distutils/command/install_lib.py b/Lib/distutils/command/install_lib.py
index e9cd80d..d866d8c 100644
--- a/Lib/distutils/command/install_lib.py
+++ b/Lib/distutils/command/install_lib.py
@@ -46,9 +46,9 @@
# 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 @@
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 @@
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
diff --git a/Lib/distutils/command/install_scripts.py b/Lib/distutils/command/install_scripts.py
index 5888caf..3eb3963 100644
--- a/Lib/distutils/command/install_scripts.py
+++ b/Lib/distutils/command/install_scripts.py
@@ -35,7 +35,7 @@
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
diff --git a/Lib/distutils/command/sdist.py b/Lib/distutils/command/sdist.py
index 0a57ba3..6626b9e 100644
--- a/Lib/distutils/command/sdist.py
+++ b/Lib/distutils/command/sdist.py
@@ -223,15 +223,15 @@
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 @@
# 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()