diff -r 37d3b95a289b Lib/distutils/command/bdist_rpm.py --- a/Lib/distutils/command/bdist_rpm.py Sat Sep 19 15:49:57 2015 -0400 +++ b/Lib/distutils/command/bdist_rpm.py Mon Apr 11 10:47:03 2016 -0400 @@ -331,13 +331,28 @@ rpm_cmd.append('--quiet') rpm_cmd.append(spec_path) - # Determine the binary rpm names that should be built out of this spec - # file + # Determine the rpm files that should be built out of this spec file # Note that some of these may not be really built (if the file # list is empty) nvr_string = "%{name}-%{version}-%{release}" src_rpm = nvr_string + ".src.rpm" non_src_rpm = "%{arch}/" + nvr_string + ".%{arch}.rpm" + + eval_cmd = "rpm --eval '%{?_rpmfilename}'" + + out = os.popen(eval_cmd) + try: + line = out.readline().strip() + if line: + non_src_rpm = line + + status = out.close() + if status: + raise DistutilsExecError("Failed to execute: %r" % eval_cmd) + + finally: + out.close() + q_cmd = r"rpm -q --qf '%s %s\n' --specfile '%s'" % ( src_rpm, non_src_rpm, spec_path) @@ -358,7 +373,7 @@ status = out.close() if status: - raise DistutilsExecError("Failed to execute: %s" % repr(q_cmd)) + raise DistutilsExecError("Failed to execute: %r" % q_cmd) finally: out.close()