Bug 1570250 - All the pythons do extra crazy things to stop BRP python bytecompile
Summary: All the pythons do extra crazy things to stop BRP python bytecompile
Alias: None
Product: Fedora
Classification: Fedora
Component: python3
Version: rawhide
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: Miro Hrončok
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2018-04-21 07:49 UTC by Miro Hrončok
Modified: 2018-05-02 10:44 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2018-05-02 10:44:04 UTC
Type: Bug

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1572171 0 unspecified CLOSED python2 is bytecompiled by /usr/bin/python2.7, not the built binary 2021-02-22 00:41:40 UTC

Internal Links: 1572171

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} \
# 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:


%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

 * 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

Note You need to log in before you can comment on or make changes to this bug.