[Python-checkins] cpython (2.7): Make bdist_* commands respect --skip-build passed to bdist (#10946)

eric.araujo python-checkins at python.org
Tue Aug 30 16:26:27 CEST 2011


http://hg.python.org/cpython/rev/4ff92eb1a915
changeset: 72136:4ff92eb1a915
branch: 2.7
user: Éric Araujo <merwok at netwok.org>
date: Tue Aug 30 01:48:59 2011 +0200
summary:
 Make bdist_* commands respect --skip-build passed to bdist (#10946)
files:
 Lib/distutils/command/bdist_dumb.py | 5 +-
 Lib/distutils/command/bdist_msi.py | 6 +-
 Lib/distutils/command/bdist_wininst.py | 6 +-
 Lib/distutils/tests/test_bdist.py | 49 ++++++++------
 Misc/NEWS | 3 +
 5 files changed, 44 insertions(+), 25 deletions(-)
diff --git a/Lib/distutils/command/bdist_dumb.py b/Lib/distutils/command/bdist_dumb.py
--- a/Lib/distutils/command/bdist_dumb.py
+++ b/Lib/distutils/command/bdist_dumb.py
@@ -58,7 +58,7 @@
 self.format = None
 self.keep_temp = 0
 self.dist_dir = None
- self.skip_build = 0
+ self.skip_build = None
 self.relative = 0
 self.owner = None
 self.group = None
@@ -78,7 +78,8 @@
 
 self.set_undefined_options('bdist',
 ('dist_dir', 'dist_dir'),
- ('plat_name', 'plat_name'))
+ ('plat_name', 'plat_name'),
+ ('skip_build', 'skip_build'))
 
 def run(self):
 if not self.skip_build:
diff --git a/Lib/distutils/command/bdist_msi.py b/Lib/distutils/command/bdist_msi.py
--- a/Lib/distutils/command/bdist_msi.py
+++ b/Lib/distutils/command/bdist_msi.py
@@ -131,18 +131,22 @@
 self.no_target_optimize = 0
 self.target_version = None
 self.dist_dir = None
- self.skip_build = 0
+ self.skip_build = None
 self.install_script = None
 self.pre_install_script = None
 self.versions = None
 
 def finalize_options (self):
+ self.set_undefined_options('bdist', ('skip_build', 'skip_build'))
+
 if self.bdist_dir is None:
 bdist_base = self.get_finalized_command('bdist').bdist_base
 self.bdist_dir = os.path.join(bdist_base, 'msi')
+
 short_version = get_python_version()
 if (not self.target_version) and self.distribution.has_ext_modules():
 self.target_version = short_version
+
 if self.target_version:
 self.versions = [self.target_version]
 if not self.skip_build and self.distribution.has_ext_modules()\
diff --git a/Lib/distutils/command/bdist_wininst.py b/Lib/distutils/command/bdist_wininst.py
--- a/Lib/distutils/command/bdist_wininst.py
+++ b/Lib/distutils/command/bdist_wininst.py
@@ -71,7 +71,7 @@
 self.dist_dir = None
 self.bitmap = None
 self.title = None
- self.skip_build = 0
+ self.skip_build = None
 self.install_script = None
 self.pre_install_script = None
 self.user_access_control = None
@@ -80,6 +80,8 @@
 
 
 def finalize_options (self):
+ self.set_undefined_options('bdist', ('skip_build', 'skip_build'))
+
 if self.bdist_dir is None:
 if self.skip_build and self.plat_name:
 # If build is skipped and plat_name is overridden, bdist will
@@ -89,8 +91,10 @@
 # next the command will be initialized using that name
 bdist_base = self.get_finalized_command('bdist').bdist_base
 self.bdist_dir = os.path.join(bdist_base, 'wininst')
+
 if not self.target_version:
 self.target_version = ""
+
 if not self.skip_build and self.distribution.has_ext_modules():
 short_version = get_python_version()
 if self.target_version and self.target_version != short_version:
diff --git a/Lib/distutils/tests/test_bdist.py b/Lib/distutils/tests/test_bdist.py
--- a/Lib/distutils/tests/test_bdist.py
+++ b/Lib/distutils/tests/test_bdist.py
@@ -1,42 +1,49 @@
 """Tests for distutils.command.bdist."""
+import os
 import unittest
-import sys
-import os
-import tempfile
-import shutil
 
 from test.test_support import run_unittest
 
-from distutils.core import Distribution
 from distutils.command.bdist import bdist
 from distutils.tests import support
-from distutils.spawn import find_executable
-from distutils import spawn
-from distutils.errors import DistutilsExecError
+
 
 class BuildTestCase(support.TempdirManager,
 unittest.TestCase):
 
 def test_formats(self):
-
 # let's create a command and make sure
- # we can fix the format
- pkg_pth, dist = self.create_dist()
+ # we can set the format
+ dist = self.create_dist()[1]
 cmd = bdist(dist)
 cmd.formats = ['msi']
 cmd.ensure_finalized()
 self.assertEqual(cmd.formats, ['msi'])
 
- # what format bdist offers ?
- # XXX an explicit list in bdist is
- # not the best way to bdist_* commands
- # we should add a registry
- formats = ['rpm', 'zip', 'gztar', 'bztar', 'ztar',
- 'tar', 'wininst', 'msi']
- formats.sort()
- founded = cmd.format_command.keys()
- founded.sort()
- self.assertEqual(founded, formats)
+ # what formats does bdist offer?
+ formats = ['bztar', 'gztar', 'msi', 'rpm', 'tar',
+ 'wininst', 'zip', 'ztar']
+ found = sorted(cmd.format_command)
+ self.assertEqual(found, formats)
+
+ def test_skip_build(self):
+ # bug #10946: bdist --skip-build should trickle down to subcommands
+ dist = self.create_dist()[1]
+ cmd = bdist(dist)
+ cmd.skip_build = 1
+ cmd.ensure_finalized()
+ dist.command_obj['bdist'] = cmd
+
+ names = ['bdist_dumb', 'bdist_wininst']
+ # bdist_rpm does not support --skip-build
+ if os.name == 'nt':
+ names.append('bdist_msi')
+
+ for name in names:
+ subcmd = cmd.get_finalized_command(name)
+ self.assertTrue(subcmd.skip_build,
+ '%s should take --skip-build from bdist' % name)
+
 
 def test_suite():
 return unittest.makeSuite(BuildTestCase)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -40,6 +40,9 @@
 Library
 -------
 
+- Issue #10946: The distutils commands bdist_dumb, bdist_wininst and bdist_msi
+ now respect a --skip-build option given to bdist.
+
 - Issue #12287: Fix a stack corruption in ossaudiodev module when the FD is
 greater than FD_SETSIZE.
 
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /