mirror of https://github.com/python/cpython.git
Make bdist_* commands respect --skip-build passed to bdist (#10946).
There was already a test for this, but it was complicated and had a subtle bug (custom command objects need to be put in dist.command_obj so that other command objects may see them) that rendered it moot.
This commit is contained in:
parent
83ab3f319b
commit
b9fe54cccc
|
@ -55,7 +55,7 @@ def initialize_options(self):
|
||||||
self.format = None
|
self.format = None
|
||||||
self.keep_temp = False
|
self.keep_temp = False
|
||||||
self.dist_dir = None
|
self.dist_dir = None
|
||||||
self.skip_build = False
|
self.skip_build = None
|
||||||
self.relative = False
|
self.relative = False
|
||||||
self.owner = None
|
self.owner = None
|
||||||
self.group = None
|
self.group = None
|
||||||
|
@ -73,7 +73,8 @@ def finalize_options(self):
|
||||||
"don't know how to create dumb built distributions "
|
"don't know how to create dumb built distributions "
|
||||||
"on platform %s" % os.name)
|
"on platform %s" % os.name)
|
||||||
|
|
||||||
self.set_undefined_options('bdist', 'dist_dir', 'plat_name')
|
self.set_undefined_options('bdist',
|
||||||
|
'dist_dir', 'plat_name', 'skip_build')
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
if not self.skip_build:
|
if not self.skip_build:
|
||||||
|
|
|
@ -139,18 +139,22 @@ def initialize_options(self):
|
||||||
self.no_target_optimize = False
|
self.no_target_optimize = False
|
||||||
self.target_version = None
|
self.target_version = None
|
||||||
self.dist_dir = None
|
self.dist_dir = None
|
||||||
self.skip_build = False
|
self.skip_build = None
|
||||||
self.install_script = None
|
self.install_script = None
|
||||||
self.pre_install_script = None
|
self.pre_install_script = None
|
||||||
self.versions = None
|
self.versions = None
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
|
self.set_undefined_options('bdist', 'skip_build')
|
||||||
|
|
||||||
if self.bdist_dir is None:
|
if self.bdist_dir is None:
|
||||||
bdist_base = self.get_finalized_command('bdist').bdist_base
|
bdist_base = self.get_finalized_command('bdist').bdist_base
|
||||||
self.bdist_dir = os.path.join(bdist_base, 'msi')
|
self.bdist_dir = os.path.join(bdist_base, 'msi')
|
||||||
|
|
||||||
short_version = get_python_version()
|
short_version = get_python_version()
|
||||||
if (not self.target_version) and self.distribution.has_ext_modules():
|
if (not self.target_version) and self.distribution.has_ext_modules():
|
||||||
self.target_version = short_version
|
self.target_version = short_version
|
||||||
|
|
||||||
if self.target_version:
|
if self.target_version:
|
||||||
self.versions = [self.target_version]
|
self.versions = [self.target_version]
|
||||||
if not self.skip_build and self.distribution.has_ext_modules()\
|
if not self.skip_build and self.distribution.has_ext_modules()\
|
||||||
|
|
|
@ -67,13 +67,15 @@ def initialize_options(self):
|
||||||
self.dist_dir = None
|
self.dist_dir = None
|
||||||
self.bitmap = None
|
self.bitmap = None
|
||||||
self.title = None
|
self.title = None
|
||||||
self.skip_build = False
|
self.skip_build = None
|
||||||
self.install_script = None
|
self.install_script = None
|
||||||
self.pre_install_script = None
|
self.pre_install_script = None
|
||||||
self.user_access_control = None
|
self.user_access_control = None
|
||||||
|
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
|
self.set_undefined_options('bdist', 'skip_build')
|
||||||
|
|
||||||
if self.bdist_dir is None:
|
if self.bdist_dir is None:
|
||||||
if self.skip_build and self.plat_name:
|
if self.skip_build and self.plat_name:
|
||||||
# If build is skipped and plat_name is overridden, bdist will
|
# If build is skipped and plat_name is overridden, bdist will
|
||||||
|
@ -83,8 +85,10 @@ def finalize_options(self):
|
||||||
# next the command will be initialized using that name
|
# next the command will be initialized using that name
|
||||||
bdist_base = self.get_finalized_command('bdist').bdist_base
|
bdist_base = self.get_finalized_command('bdist').bdist_base
|
||||||
self.bdist_dir = os.path.join(bdist_base, 'wininst')
|
self.bdist_dir = os.path.join(bdist_base, 'wininst')
|
||||||
|
|
||||||
if not self.target_version:
|
if not self.target_version:
|
||||||
self.target_version = ""
|
self.target_version = ""
|
||||||
|
|
||||||
if not self.skip_build and self.distribution.has_ext_modules():
|
if not self.skip_build and self.distribution.has_ext_modules():
|
||||||
short_version = get_python_version()
|
short_version = get_python_version()
|
||||||
if self.target_version and self.target_version != short_version:
|
if self.target_version and self.target_version != short_version:
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
"""Tests for distutils.command.bdist."""
|
"""Tests for distutils.command.bdist."""
|
||||||
|
import os
|
||||||
from packaging import util
|
|
||||||
from packaging.command.bdist import bdist, show_formats
|
from packaging.command.bdist import bdist, show_formats
|
||||||
|
|
||||||
from packaging.tests import unittest, support, captured_stdout
|
from packaging.tests import unittest, support, captured_stdout
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,22 +8,6 @@ class BuildTestCase(support.TempdirManager,
|
||||||
support.LoggingCatcher,
|
support.LoggingCatcher,
|
||||||
unittest.TestCase):
|
unittest.TestCase):
|
||||||
|
|
||||||
def _mock_get_platform(self):
|
|
||||||
self._get_platform_called = True
|
|
||||||
return self._get_platform()
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
super(BuildTestCase, self).setUp()
|
|
||||||
|
|
||||||
# mock util.get_platform
|
|
||||||
self._get_platform_called = False
|
|
||||||
self._get_platform = util.get_platform
|
|
||||||
util.get_platform = self._mock_get_platform
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
super(BuildTestCase, self).tearDown()
|
|
||||||
util.get_platform = self._get_platform
|
|
||||||
|
|
||||||
def test_formats(self):
|
def test_formats(self):
|
||||||
# let's create a command and make sure
|
# let's create a command and make sure
|
||||||
# we can set the format
|
# we can set the format
|
||||||
|
@ -35,7 +17,7 @@ def test_formats(self):
|
||||||
cmd.ensure_finalized()
|
cmd.ensure_finalized()
|
||||||
self.assertEqual(cmd.formats, ['msi'])
|
self.assertEqual(cmd.formats, ['msi'])
|
||||||
|
|
||||||
# what format does bdist offer?
|
# what formats does bdist offer?
|
||||||
# XXX hard-coded lists are not the best way to find available bdist_*
|
# XXX hard-coded lists are not the best way to find available bdist_*
|
||||||
# commands; we should add a registry
|
# commands; we should add a registry
|
||||||
formats = ['bztar', 'gztar', 'msi', 'tar', 'wininst', 'zip']
|
formats = ['bztar', 'gztar', 'msi', 'tar', 'wininst', 'zip']
|
||||||
|
@ -43,19 +25,21 @@ def test_formats(self):
|
||||||
self.assertEqual(found, formats)
|
self.assertEqual(found, formats)
|
||||||
|
|
||||||
def test_skip_build(self):
|
def test_skip_build(self):
|
||||||
dist = self.create_dist()[1]
|
# bug #10946: bdist --skip-build should trickle down to subcommands
|
||||||
cmd = bdist(dist)
|
|
||||||
cmd.skip_build = False
|
|
||||||
cmd.formats = ['ztar']
|
|
||||||
cmd.ensure_finalized()
|
|
||||||
self.assertFalse(self._get_platform_called)
|
|
||||||
|
|
||||||
dist = self.create_dist()[1]
|
dist = self.create_dist()[1]
|
||||||
cmd = bdist(dist)
|
cmd = bdist(dist)
|
||||||
cmd.skip_build = True
|
cmd.skip_build = True
|
||||||
cmd.formats = ['ztar']
|
|
||||||
cmd.ensure_finalized()
|
cmd.ensure_finalized()
|
||||||
self.assertTrue(self._get_platform_called)
|
dist.command_obj['bdist'] = cmd
|
||||||
|
|
||||||
|
names = ['bdist_dumb', 'bdist_wininst']
|
||||||
|
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_show_formats(self):
|
def test_show_formats(self):
|
||||||
__, stdout = captured_stdout(show_formats)
|
__, stdout = captured_stdout(show_formats)
|
||||||
|
|
|
@ -269,7 +269,8 @@ Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
- Issue #10946: The distutils commands bdist_dumb, bdist_wininst and bdist_msi
|
- Issue #10946: The distutils commands bdist_dumb, bdist_wininst and bdist_msi
|
||||||
now respect a --skip-build option given to bdist.
|
now respect a --skip-build option given to bdist. The packaging commands
|
||||||
|
were fixed too.
|
||||||
|
|
||||||
- Issue #12287: Fix a stack corruption in ossaudiodev module when the FD is
|
- Issue #12287: Fix a stack corruption in ossaudiodev module when the FD is
|
||||||
greater than FD_SETSIZE.
|
greater than FD_SETSIZE.
|
||||||
|
|
Loading…
Reference in New Issue