diff -r e3c9a47a83fb Lib/distutils/command/bdist_rpm.py --- a/Lib/distutils/command/bdist_rpm.py Mon Apr 11 17:33:27 2016 +0300 +++ b/Lib/distutils/command/bdist_rpm.py Mon Apr 11 18:02:33 2016 -0400 @@ -331,13 +331,23 @@ 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}") + + try: + out = subprocess.check_output(eval_cmd) + except (OSError, subprocess.CalledProcessError): + raise DistutilsExecError("Failed to execute: %r" % (eval_cmd,)) + + non_src_rpm = out.decode('ascii').rstrip() + if not non_src_rpm: + non_src_rpm = "%{arch}/" + nvr_string + ".%{arch}.rpm" + q_cmd = r"rpm -q --qf '%s %s\n' --specfile '%s'" % ( src_rpm, non_src_rpm, spec_path)