mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
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.
This commit is contained in:
parent
72a80e85a8
commit
b83719287d
2 changed files with 19 additions and 1 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
Implements the Distutils 'bdist_rpm' command (create RPM source and binary
|
Implements the Distutils 'bdist_rpm' command (create RPM source and binary
|
||||||
distributions)."""
|
distributions)."""
|
||||||
|
|
||||||
import sys, os
|
import subprocess, sys, os
|
||||||
from distutils.core import Command
|
from distutils.core import Command
|
||||||
from distutils.debug import DEBUG
|
from distutils.debug import DEBUG
|
||||||
from distutils.util import get_platform
|
from distutils.util import get_platform
|
||||||
|
|
@ -406,6 +406,21 @@ class bdist_rpm(Command):
|
||||||
'Summary: ' + self.distribution.get_description(),
|
'Summary: ' + self.distribution.get_description(),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Workaround for #14443 which affects some RPM based systems such as
|
||||||
|
# RHEL6 (and probably derivatives)
|
||||||
|
vendor_hook = subprocess.getoutput('rpm --eval %{__os_install_post}')
|
||||||
|
# Generate a potential replacement value for __os_install_post (whilst
|
||||||
|
# normalizing the whitespace to simplify the test for whether the
|
||||||
|
# invocation of brp-python-bytecompile passes in __python):
|
||||||
|
vendor_hook = '\n'.join([' %s \\' % line.strip()
|
||||||
|
for line in vendor_hook.splitlines()])
|
||||||
|
problem = "brp-python-bytecompile \\\n"
|
||||||
|
fixed = "brp-python-bytecompile %{__python} \\\n"
|
||||||
|
fixed_hook = vendor_hook.replace(problem, fixed)
|
||||||
|
if fixed_hook != vendor_hook:
|
||||||
|
spec_file.append('# Workaround for http://bugs.python.org/issue14443')
|
||||||
|
spec_file.append('%define __os_install_post ' + fixed_hook + '\n')
|
||||||
|
|
||||||
# put locale summaries into spec file
|
# put locale summaries into spec file
|
||||||
# XXX not supported for now (hard to put a dictionary
|
# XXX not supported for now (hard to put a dictionary
|
||||||
# in a config file -- arg!)
|
# in a config file -- arg!)
|
||||||
|
|
|
||||||
|
|
@ -1138,6 +1138,9 @@ Library
|
||||||
- Issue #12451: xml.dom.pulldom: parse() now opens files in binary mode instead
|
- Issue #12451: xml.dom.pulldom: parse() now opens files in binary mode instead
|
||||||
of the text mode (using the locale encoding) to avoid encoding issues.
|
of the text mode (using the locale encoding) to avoid encoding issues.
|
||||||
|
|
||||||
|
- Issue #14443: Ensure that .py files are byte-compiled with the correct Python
|
||||||
|
executable within bdist_rpm even on older versions of RPM
|
||||||
|
|
||||||
Extension Modules
|
Extension Modules
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue