diff -r 23d9daed4b14 Lib/distutils/command/bdist_rpm.py --- a/Lib/distutils/command/bdist_rpm.py Tue Mar 04 23:22:15 2014 +0000 +++ b/Lib/distutils/command/bdist_rpm.py Sun Mar 09 02:34:32 2014 -0300 @@ -512,10 +512,14 @@ # XXX this is kind of misleading: user-supplied options are files # that we open and interpolate into the spec file, but the defaults # are just text that we drop in as-is. Hmmm. - - install_cmd = ('%s install -O1 --root=$RPM_BUILD_ROOT ' - '--record=INSTALLED_FILES') % def_setup_call - + + # if any path contain spaces, it will generate a rpmbuild error. + # using sed to put file paths between double-quotes + install_setup_call = ('%s install -O1 --root=$RPM_BUILD_ROOT ' + '--record=INSTALLED_FILES') % def_setup_call + sed_quotes = 'sed -i -e \'s\\^\\"\\\' -e \'s\\$\\"\\\' INSTALLED_FILES' + install_cmd = '%s && %s' % (install_setup_call, sed_quotes) + script_options = [ ('prep', 'prep_script', "%setup -n %{name}-%{unmangled_version}"), ('build', 'build_script', def_build), diff -r 23d9daed4b14 Lib/distutils/tests/test_bdist_rpm.py --- a/Lib/distutils/tests/test_bdist_rpm.py Tue Mar 04 23:22:15 2014 +0000 +++ b/Lib/distutils/tests/test_bdist_rpm.py Sun Mar 09 02:34:32 2014 -0300 @@ -5,6 +5,7 @@ import os import tempfile import shutil +import textwrap from test.support import run_unittest from distutils.core import Distribution @@ -93,6 +94,59 @@ 'the rpm command is not found') @unittest.skipIf(find_executable('rpmbuild') is None, 'the rpmbuild command is not found') + def test_filename_with_whitespace(self): + SETUP_PY_WS = textwrap.dedent(""" + + from distutils.core import setup + import foo + + setup(name='foo', version='0.1', + py_modules=['foo', 'foo_with space'], + url='xxx', author='xxx', + author_email='xxx') + + """) + + # let's create a package with 2 files in it + tmp_dir = self.mkdtemp() + pkg_dir = os.path.join(tmp_dir, 'foo') + os.mkdir(pkg_dir) + self.write_file((pkg_dir, 'setup.py'), SETUP_PY_WS) + self.write_file((pkg_dir, 'foo.py'), '#') + self.write_file((pkg_dir, 'foo_with space.py'), '#') + self.write_file((pkg_dir, 'MANIFEST.in'), + 'include foo.py\n' + + 'include foo_with space.py') + self.write_file((pkg_dir, 'README'), '') + + dist = Distribution({'name': 'foo', 'version': '0.1', + 'py_modules': ['foo', 'foo_with space'], + 'url': 'xxx', 'author': 'xxx', + 'author_email': 'xxx'}) + dist.script_name = 'setup.py' + os.chdir(pkg_dir) + + sys.argv = ['setup.py'] + cmd = bdist_rpm(dist) + cmd.fix_python = True + + # running in quiet mode + cmd.quiet = 1 + cmd.ensure_finalized() + cmd.run() + + dist_created = os.listdir(os.path.join(pkg_dir, 'dist')) + self.assertTrue('foo-0.1-1.noarch.rpm' in dist_created) + + # XXX I am unable yet to make this test work without + # spurious sdtout/stderr output under Mac OS X + @unittest.skipUnless(sys.platform.startswith('linux'), + 'spurious sdtout/stderr output under Mac OS X') + # http://bugs.python.org/issue1533164 + @unittest.skipIf(find_executable('rpm') is None, + 'the rpm command is not found') + @unittest.skipIf(find_executable('rpmbuild') is None, + 'the rpmbuild command is not found') def test_no_optimize_flag(self): # let's create a package that brakes bdist_rpm tmp_dir = self.mkdtemp()