cpython: a9a12ad553f0 (original) (raw)
Mercurial > cpython
changeset 77780:a9a12ad553f0
Issue #14443: ensure that brp-python-bytecompile is invoked with the correct python executable The __os_install_macro defines some post-processing activities during an rpm build; one of the scripts it calls is brp-python-bytecompile, which can take an argument: the python executable with which to byte-compile .py files in the package payload. In some older versions of rpm (e.g. in RHEL 6), this invocation doesn't pass in an argument, and brp-python-bytecompile defaults to using /usr/bin/python, which can lead to the .py files being byte-compiled for the wrong version of python. This has been fixed in later versions of rpm by passing in %{__python} as an argument to brp-python-bytecompile. Workaround this by detecting if __os_install_post has a 0-argument invocation of brp-python-bytecompile, and if so generating an equivalent macro that has the argument, and explicitly provide the new definition within the specfile. [#14443]
David Malcolm dmalcolm@redhat.com | |
---|---|
date | Mon, 25 Jun 2012 15:52:24 -0400 |
parents | e6bac47a2cd9 |
children | 85e8d2f9b33e |
files | Lib/distutils/command/bdist_rpm.py Misc/NEWS |
diffstat | 2 files changed, 19 insertions(+), 1 deletions(-)[+] [-] Lib/distutils/command/bdist_rpm.py 17 Misc/NEWS 3 |
line wrap: on
line diff
--- a/Lib/distutils/command/bdist_rpm.py +++ b/Lib/distutils/command/bdist_rpm.py @@ -3,7 +3,7 @@ Implements the Distutils 'bdist_rpm' command (create RPM source and binary distributions).""" -import sys, os +import subprocess, sys, os from distutils.core import Command from distutils.debug import DEBUG from distutils.util import get_platform @@ -406,6 +406,21 @@ class bdist_rpm(Command): 'Summary: ' + self.distribution.get_description(), ]
# Workaround for #14443 which affects some RPM based systems such as[](#l1.16)
# RHEL6 (and probably derivatives)[](#l1.17)
vendor_hook = subprocess.getoutput('rpm --eval %{__os_install_post}')[](#l1.18)
# Generate a potential replacement value for __os_install_post (whilst[](#l1.19)
# normalizing the whitespace to simplify the test for whether the[](#l1.20)
# invocation of brp-python-bytecompile passes in __python):[](#l1.21)
vendor_hook = '\n'.join([' %s \\' % line.strip()[](#l1.22)
for line in vendor_hook.splitlines()])[](#l1.23)
problem = "brp-python-bytecompile \\\n"[](#l1.24)
fixed = "brp-python-bytecompile %{__python} \\\n"[](#l1.25)
fixed_hook = vendor_hook.replace(problem, fixed)[](#l1.26)
if fixed_hook != vendor_hook:[](#l1.27)
spec_file.append('# Workaround for http://bugs.python.org/issue14443')[](#l1.28)
spec_file.append('%define __os_install_post ' + fixed_hook + '\n')[](#l1.29)
+ # put locale summaries into spec file # XXX not supported for now (hard to put a dictionary # in a config file -- arg!)