summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author?ric Araujo <merwok@netwok.org>2010-08-04 18:12:31 +0200
committer?ric Araujo <merwok@netwok.org>2010-08-04 18:12:31 +0200
commit0b02c86cc41e8dd4d79a2a16cb967fb3e9707c51 (patch)
tree1b61dec2dc788561e5502c58f03ae84f6c06afca /src
parentecafc4a7a33543b2975cd8b527ce34c902c9ec87 (diff)
downloaddisutils2-0b02c86cc41e8dd4d79a2a16cb967fb3e9707c51.tar.gz
Make set_undefined_options more friendly
Diffstat (limited to 'src')
-rw-r--r--src/distutils2/command/bdist_dumb.py4
-rw-r--r--src/distutils2/command/bdist_msi.py5
-rw-r--r--src/distutils2/command/bdist_wininst.py5
-rw-r--r--src/distutils2/command/build_clib.py4
-rw-r--r--src/distutils2/command/build_ext.py9
-rw-r--r--src/distutils2/command/build_py.py4
-rw-r--r--src/distutils2/command/build_scripts.py3
-rw-r--r--src/distutils2/command/clean.py10
-rw-r--r--src/distutils2/command/cmd.py38
-rw-r--r--src/distutils2/command/install.py4
-rw-r--r--src/distutils2/command/install_data.py4
-rw-r--r--src/distutils2/command/install_headers.py3
-rw-r--r--src/distutils2/command/install_lib.py6
-rw-r--r--src/distutils2/command/install_scripts.py4
14 files changed, 37 insertions, 66 deletions
diff --git a/src/distutils2/command/bdist_dumb.py b/src/distutils2/command/bdist_dumb.py
index 604bcb7..4113a1e 100644
--- a/src/distutils2/command/bdist_dumb.py
+++ b/src/distutils2/command/bdist_dumb.py
@@ -77,9 +77,7 @@ class bdist_dumb (Command):
("don't know how to create dumb built distributions " +
"on platform %s") % os.name
- self.set_undefined_options('bdist',
- ('dist_dir', 'dist_dir'),
- ('plat_name', 'plat_name'))
+ self.set_undefined_options('bdist', 'dist_dir', 'plat_name')
def run(self):
if not self.skip_build:
diff --git a/src/distutils2/command/bdist_msi.py b/src/distutils2/command/bdist_msi.py
index bbbcbcc..b759a06 100644
--- a/src/distutils2/command/bdist_msi.py
+++ b/src/distutils2/command/bdist_msi.py
@@ -153,10 +153,7 @@ class bdist_msi (Command):
else:
self.versions = list(self.all_versions)
- self.set_undefined_options('bdist',
- ('dist_dir', 'dist_dir'),
- ('plat_name', 'plat_name'),
- )
+ self.set_undefined_options('bdist', 'dist_dir', 'plat_name')
if self.pre_install_script:
raise DistutilsOptionError, "the pre-install-script feature is not yet implemented"
diff --git a/src/distutils2/command/bdist_wininst.py b/src/distutils2/command/bdist_wininst.py
index dd2b8ba..264f4fb 100644
--- a/src/distutils2/command/bdist_wininst.py
+++ b/src/distutils2/command/bdist_wininst.py
@@ -100,10 +100,7 @@ class bdist_wininst (Command):
" option must be specified" % (short_version,)
self.target_version = short_version
- self.set_undefined_options('bdist',
- ('dist_dir', 'dist_dir'),
- ('plat_name', 'plat_name'),
- )
+ self.set_undefined_options('bdist', 'dist_dir', 'plat_name')
if self.install_script:
for script in self.distribution.scripts:
diff --git a/src/distutils2/command/build_clib.py b/src/distutils2/command/build_clib.py
index 40c4b6e..0a25aa8 100644
--- a/src/distutils2/command/build_clib.py
+++ b/src/distutils2/command/build_clib.py
@@ -76,9 +76,7 @@ class build_clib(Command):
self.set_undefined_options('build',
('build_temp', 'build_clib'),
('build_temp', 'build_temp'),
- ('compiler', 'compiler'),
- ('debug', 'debug'),
- ('force', 'force'))
+ 'compiler', 'debug', 'force')
self.libraries = self.distribution.libraries
if self.libraries:
diff --git a/src/distutils2/command/build_ext.py b/src/distutils2/command/build_ext.py
index 4428b71..29530eb 100644
--- a/src/distutils2/command/build_ext.py
+++ b/src/distutils2/command/build_ext.py
@@ -177,13 +177,8 @@ class build_ext(Command):
def finalize_options(self):
self.set_undefined_options('build',
- ('build_lib', 'build_lib'),
- ('build_temp', 'build_temp'),
- ('compiler', 'compiler'),
- ('debug', 'debug'),
- ('force', 'force'),
- ('plat_name', 'plat_name'),
- )
+ 'build_lib', 'build_temp', 'compiler',
+ 'debug', 'force', 'plat_name')
if self.package is None:
self.package = self.distribution.ext_package
diff --git a/src/distutils2/command/build_py.py b/src/distutils2/command/build_py.py
index c4c6d68..a805a1e 100644
--- a/src/distutils2/command/build_py.py
+++ b/src/distutils2/command/build_py.py
@@ -95,9 +95,7 @@ class build_py(Command, Mixin2to3):
self._doctests_2to3 = []
def finalize_options(self):
- self.set_undefined_options('build',
- ('build_lib', 'build_lib'),
- ('force', 'force'))
+ self.set_undefined_options('build', 'build_lib', 'force')
# Get the distribution options that are aliases for build_py
# options -- list of packages and list of modules.
diff --git a/src/distutils2/command/build_scripts.py b/src/distutils2/command/build_scripts.py
index ad1c234..b62ade7 100644
--- a/src/distutils2/command/build_scripts.py
+++ b/src/distutils2/command/build_scripts.py
@@ -40,8 +40,7 @@ class build_scripts (Command):
def finalize_options (self):
self.set_undefined_options('build',
('build_scripts', 'build_dir'),
- ('force', 'force'),
- ('executable', 'executable'))
+ 'force', 'executable')
self.scripts = self.distribution.scripts
def get_source_files(self):
diff --git a/src/distutils2/command/clean.py b/src/distutils2/command/clean.py
index baeaf05..8125dcd 100644
--- a/src/distutils2/command/clean.py
+++ b/src/distutils2/command/clean.py
@@ -40,13 +40,9 @@ class clean(Command):
self.all = None
def finalize_options(self):
- self.set_undefined_options('build',
- ('build_base', 'build_base'),
- ('build_lib', 'build_lib'),
- ('build_scripts', 'build_scripts'),
- ('build_temp', 'build_temp'))
- self.set_undefined_options('bdist',
- ('bdist_base', 'bdist_base'))
+ self.set_undefined_options('build', 'build_base', 'build_lib',
+ 'build_scripts', 'build_temp')
+ self.set_undefined_options('bdist', 'bdist_base')
def run(self):
# remove the build/temp.<plat> directory (unless it's already
diff --git a/src/distutils2/command/cmd.py b/src/distutils2/command/cmd.py
index fa6f281..5acfb32 100644
--- a/src/distutils2/command/cmd.py
+++ b/src/distutils2/command/cmd.py
@@ -297,26 +297,30 @@ class Command(object):
else:
return self.__class__.__name__
- def set_undefined_options(self, src_cmd, *option_pairs):
- """Set the values of any "undefined" options from corresponding
- option values in some other command object. "Undefined" here means
- "is None", which is the convention used to indicate that an option
- has not been changed between 'initialize_options()' and
- 'finalize_options()'. Usually called from 'finalize_options()' for
- options that depend on some other command rather than another
- option of the same command. 'src_cmd' is the other command from
- which option values will be taken (a command object will be created
- for it if necessary); the remaining arguments are
- '(src_option,dst_option)' tuples which mean "take the value of
- 'src_option' in the 'src_cmd' command object, and copy it to
- 'dst_option' in the current command object".
+ def set_undefined_options(self, src_cmd, *options):
+ """Set values of undefined options from another command.
+
+ Undefined options are options set to None, which is the convention
+ used to indicate that an option has not been changed between
+ 'initialize_options()' and 'finalize_options()'. This method is
+ usually called from 'finalize_options()' for options that depend on
+ some other command rather than another option of the same command,
+ typically subcommands.
+
+ The 'src_cmd' argument is the other command from which option values
+ will be taken (a command object will be created for it if necessary);
+ the remaining positional arguments are strings that give the name of
+ the option to set. If the name is different on the source and target
+ command, you can pass a tuple with '(name_on_source, name_on_dest)' so
+ that 'self.name_on_dest' will be set from 'src_cmd.name_on_source'.
"""
-
- # Option_pairs: list of (src_option, dst_option) tuples
-
src_cmd_obj = self.distribution.get_command_obj(src_cmd)
src_cmd_obj.ensure_finalized()
- for (src_option, dst_option) in option_pairs:
+ for obj in options:
+ if isinstance(obj, tuple):
+ src_option, dst_option = obj
+ else:
+ src_option, dst_option = obj, obj
if getattr(self, dst_option) is None:
setattr(self, dst_option,
getattr(src_cmd_obj, src_option))
diff --git a/src/distutils2/command/install.py b/src/distutils2/command/install.py
index be9eefb..92c74ad 100644
--- a/src/distutils2/command/install.py
+++ b/src/distutils2/command/install.py
@@ -317,9 +317,7 @@ class install(Command):
self.dump_dirs("after prepending root")
# Find out the build directories, ie. where to install from.
- self.set_undefined_options('build',
- ('build_base', 'build_base'),
- ('build_lib', 'build_lib'))
+ self.set_undefined_options('build', 'build_base', 'build_lib')
# Punt on doc directories for now -- after all, we're punting on
# documentation completely!
diff --git a/src/distutils2/command/install_data.py b/src/distutils2/command/install_data.py
index 06b0a33..5b06b5a 100644
--- a/src/distutils2/command/install_data.py
+++ b/src/distutils2/command/install_data.py
@@ -37,9 +37,7 @@ class install_data(Command):
def finalize_options(self):
self.set_undefined_options('install',
('install_data', 'install_dir'),
- ('root', 'root'),
- ('force', 'force'),
- )
+ 'root', 'force')
def run(self):
self.mkpath(self.install_dir)
diff --git a/src/distutils2/command/install_headers.py b/src/distutils2/command/install_headers.py
index 762656d..dd63128 100644
--- a/src/distutils2/command/install_headers.py
+++ b/src/distutils2/command/install_headers.py
@@ -29,8 +29,7 @@ class install_headers(Command):
def finalize_options(self):
self.set_undefined_options('install',
('install_headers', 'install_dir'),
- ('force', 'force'))
-
+ 'force')
def run(self):
headers = self.distribution.headers
diff --git a/src/distutils2/command/install_lib.py b/src/distutils2/command/install_lib.py
index 7a9023b..c5e78f7 100644
--- a/src/distutils2/command/install_lib.py
+++ b/src/distutils2/command/install_lib.py
@@ -68,11 +68,7 @@ class install_lib(Command):
self.set_undefined_options('install',
('build_lib', 'build_dir'),
('install_lib', 'install_dir'),
- ('force', 'force'),
- ('compile', 'compile'),
- ('optimize', 'optimize'),
- ('skip_build', 'skip_build'),
- )
+ 'force', 'compile', 'optimize', 'skip_build')
if self.compile is None:
self.compile = 1
diff --git a/src/distutils2/command/install_scripts.py b/src/distutils2/command/install_scripts.py
index bdf7362..fa7587e 100644
--- a/src/distutils2/command/install_scripts.py
+++ b/src/distutils2/command/install_scripts.py
@@ -36,9 +36,7 @@ class install_scripts (Command):
self.set_undefined_options('build', ('build_scripts', 'build_dir'))
self.set_undefined_options('install',
('install_scripts', 'install_dir'),
- ('force', 'force'),
- ('skip_build', 'skip_build'),
- )
+ 'force', 'skip_build')
def run (self):
if not self.skip_build: