#87 No more automagic Python bytecompilation (phase 3)
Merged 3 years ago by churchyard. Opened 3 years ago by lbalhar.
rpms/ lbalhar/redhat-rpm-config master  into  master

file modified
+10 -33
@@ -1,6 +1,15 @@ 

  #!/bin/bash

  errors_terminate=$2

+ 

+ # Usage of %_python_bytecompile_extra is not allowed anymore

+ # See: https://fedoraproject.org/wiki/Changes/No_more_automagic_Python_bytecompilation_phase_3

+ # Therefore $1 ($default_python) is not needed and is invoked with "" by default.

+ # $default_python stays in the arguments for backward compatibility and $extra for the following check:

  extra=$3

+ if [ 0$extra -eq 1 ]; then

+     echo -e "%_python_bytecompile_extra is discontinued, use %py_byte_compile instead.\nSee: https://fedoraproject.org/wiki/Changes/No_more_automagic_Python_bytecompilation_phase_3" >/dev/stderr

+     exit 1

+ fi

  

  # If using normal root, avoid changing anything.

  if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
@@ -85,7 +94,7 @@ 

  #

  # Support this by assuming that below each /usr/lib/python$VERSION/, all

  # .pyc/.pyo files are to be compiled for /usr/bin/python$VERSION.

- # 

+ #

  # For example, below /usr/lib/python2.6/, we're targeting /usr/bin/python2.6

  # and below /usr/lib/python3.1/, we're targeting /usr/bin/python3.1

  
@@ -110,35 +119,3 @@ 

  		exit 1

  	fi

  done

- 

- 

- # Handle other locations in the filesystem using the default python implementation

- # if extra is set to 0, don't do this

- if [ 0$extra -eq 0 ]; then

- 	exit 0

- fi

- 

- # If we don't have a default python interpreter, we cannot proceed

- default_python=${1:-/usr/bin/python}

- if [ ! -x "$default_python" ]; then

- 	exit 0

- fi

- 

- # Figure out if there are files to be bytecompiled with the default_python at all

- # this prevents unnecessary default_python invocation

- find "$RPM_BUILD_ROOT" -type f -name "*.py" | grep -Ev "/bin/|/sbin/|/usr/lib(64)?/python[0-9]\.[0-9]|/usr/share/doc" || exit 0

- 

- # Generate normal (.pyc) byte-compiled files.

- python_bytecompile "" $default_python "/bin/|/sbin/|/usr/lib(64)?/python[0-9]\.[0-9]|/usr/share/doc" "$RPM_BUILD_ROOT" "$depth" "/"

- if [ $? -ne 0 -a 0$errors_terminate -ne 0 ]; then

- 	# One or more of the files had a syntax error

- 	exit 1

- fi

- 

- # Generate optimized (.pyo) byte-compiled files.

- python_bytecompile "-O" $default_python "/bin/|/sbin/|/usr/lib(64)?/python[0-9]\.[0-9]|/usr/share/doc" "$RPM_BUILD_ROOT" "$depth" "/"

- if [ $? -ne 0 -a 0$errors_terminate -ne 0 ]; then

- 	# One or more of the files had a syntax error

- 	exit 1

- fi

- exit 0

file modified
+1 -1
@@ -232,7 +232,7 @@ 

  %__brp_strip_lto /usr/lib/rpm/redhat/brp-strip-lto %{__strip}

  %__brp_strip_comment_note /usr/lib/rpm/brp-strip-comment-note %{__strip} %{__objdump}

  %__brp_strip_static_archive /usr/lib/rpm/brp-strip-static-archive %{__strip}

- %__brp_python_bytecompile /usr/lib/rpm/redhat/brp-python-bytecompile "%{__python}" "%{?_python_bytecompile_errors_terminate_build}" "%{?_python_bytecompile_extra}"

+ %__brp_python_bytecompile /usr/lib/rpm/redhat/brp-python-bytecompile "" "%{?_python_bytecompile_errors_terminate_build}" "%{?_python_bytecompile_extra}"

  %__brp_python_hardlink /usr/lib/rpm/brp-python-hardlink

  # __brp_mangle_shebangs_exclude - shebangs to exclude

  # __brp_mangle_shebangs_exclude_file - file from which to get shebangs to exclude

file modified
+5 -1
@@ -6,7 +6,7 @@ 

  

  Summary: Red Hat specific rpm configuration files

  Name: redhat-rpm-config

- Version: 160

+ Version: 161

  Release: 1%{?dist}

  # No version specified.

  License: GPL+
@@ -207,6 +207,10 @@ 

  %{_rpmconfigdir}/macros.d/macros.kmp

  

  %changelog

+ * Mon Jun 15 2020 Lumír Balhar <lbalhar@redhat.com> - 161-1

+ - No more automagic Python bytecompilation (phase 3)

+   https://fedoraproject.org/wiki/Changes/No_more_automagic_Python_bytecompilation_phase_3

+ 

  * Thu Jun 04 2020 Igor Raits <ignatenkobrain@fedoraproject.org> - 160-1

  - Fix broken %%configure

  

and equals -> and is invoked with

Please avoid unrelated whitespace fixes, it makes it hard when git blaming things.

nicer link here as well? possibly indent to match line above?

Change looks good. My comments are only nitpicks. Thanks.

All nitpicks fixed, except:

Please avoid unrelated whitespace fixes, it makes it hard when git blaming things.

I'd really like to have it fixed so I've removed the trailing whitespace in a separated commit.

rebased onto d4e004cc657d0b4f578e3f0b297b80402f1ab11b

3 years ago

separate commit is fine, thanks.

this mixes tabs a and spaces

  1. echo does not support \n unless echo -e is used. 2. consider echoing errors to stderr (not sure if rest of the script does that, so feel free to ignore this for consistency)

2 more nitpicks, sorry for not noticing them sooner

rebased onto bb75938bf0c7195c4eebedff192f328672fc46c4

3 years ago

Note to myself: test it before you open a PR!

Fixed, rebased, tested. This is how the error looks:

+ /usr/lib/rpm/redhat/brp-python-bytecompile '' 1 1
%_python_bytecompile_extra is discontinued, use %py_byte_compile instead.
See: https://fedoraproject.org/wiki/Changes/No_more_automagic_Python_bytecompilation_phase_3
error: Bad exit status from /var/tmp/rpm-tmp.NPMfjv (%install)
RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.NPMfjv (%install)
Child return code was: 1

Test builds: https://copr.fedorainfracloud.org/coprs/lbalhar/no_bytecompile_extra/builds/

LGTM, good riddance! :)

rebased onto ecf9fd3

3 years ago

The change is approved so I rebased this PR and I'm removing the WIP flag.

Pull-Request has been merged by churchyard

3 years ago

@lbalhar Could you please query the package list once more and send an announcement? This has been built and shipped: https://bodhi.fedoraproject.org/updates/FEDORA-2020-922b21ffde