Bug 1570250

Summary: All the pythons do extra crazy things to stop BRP python bytecompile
Product: [Fedora] Fedora Reporter: Miro Hrončok <mhroncok>
Component: python3Assignee: Miro Hrončok <mhroncok>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: bkabrda, cstratak, dmalcolm, mcyprian, mhroncok, pviktori, rkuska, shcherbina.iryna, tomspur, torsava
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-05-02 10:44:04 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Miro Hrončok 2018-04-21 07:49:27 UTC
All our Python specs have variations on:

# We want to byte-compile the .py files within the packages using the new
# python3 binary.
# 
# Unfortunately, rpmbuild's infrastructure requires us to jump through some
# hoops to avoid byte-compiling with the system python 2 version:
#   /usr/lib/rpm/redhat/macros sets up build policy that (amongst other things)
# defines __os_install_post.  In particular, "brp-python-bytecompile" is
# invoked without an argument thus using the wrong version of python
# (/usr/bin/python, rather than the freshly built python), thus leading to
# numerous syntax errors, and incorrect magic numbers in the .pyc files.  We
# thus override __os_install_post to avoid invoking this script:
%global __os_install_post /usr/lib/rpm/brp-compress \
  %{!?__debug_package:/usr/lib/rpm/brp-strip %{__strip}} \
  /usr/lib/rpm/brp-strip-static-archive %{__strip} \
  /usr/lib/rpm/brp-strip-comment-note %{__strip} %{__objdump} \
  /usr/lib/rpm/brp-python-hardlink 
# to remove the invocation of brp-python-bytecompile, whilst keeping the
# invocation of brp-python-hardlink (since this should still work for python3
# pyc/pyo files)



This effectively freezes the brp policies to the given list and disables all of the rest.
Therefor i.e. the shebang mangling never took place for the pythons themselves.

The proper way of doing this is:

F28+:

%undefine __brp_python_bytecompile

F26, F27:

%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompilespace:.*$!!g')

See https://fedoraproject.org/wiki/Packaging:Python_Appendix#Manual_byte_compilation

Comment 1 Miro Hrončok 2018-04-26 10:55:45 UTC
Update:

 * python37 was fixed already
 * pyton3 was fixed already
 * working on python35 at https://src.fedoraproject.org/rpms/python35/pull-request/9

Comment 3 Miro Hrončok 2018-04-30 10:55:23 UTC
 * python2 was not even disabling it, now it does https://src.fedoraproject.org/rpms/python2/pull-request/15

Comment 4 Miro Hrončok 2018-05-02 10:44:04 UTC
 * python26 https://src.fedoraproject.org/rpms/python26/pull-request/2