public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Panu Matilainen <pmatilai@fedoraproject.org>
To: git-commits@fedoraproject.org
Subject: [rpms/rpm] pmatilai-v6: - python byte-compilation fixes + improvements (#558997)
Date: Mon, 23 Nov 2026 09:26:24 GMT	[thread overview]
Message-ID: <179542598471.1.5945582240852987074.rpms-rpm-2981a8197746@fedoraproject.org> (raw)

A new commit has been pushed.

Repo   : rpms/rpm
Branch : pmatilai-v6
Commit : 2981a8197746bdd98ab20119229a65a68f659b5e
Author : Panu Matilainen <pmatilai@fedoraproject.org>
Date   : 2010-02-03T10:44:56+00:00
Stats  : +80/-1 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/rpm/c/2981a8197746bdd98ab20119229a65a68f659b5e?branch=pmatilai-v6

Log:
- python byte-compilation fixes + improvements (#558997)

---
diff --git a/rpm-4.8.0-python-bytecompile.patch b/rpm-4.8.0-python-bytecompile.patch
new file mode 100644
index 0000000..0bd6c0c
--- /dev/null
+++ b/rpm-4.8.0-python-bytecompile.patch
@@ -0,0 +1,74 @@
+commit 7617dfec85012a75bf15dec963f2f9a65e8550d9
+Author: Panu Matilainen <pmatilai@redhat.com>
+Date:   Wed Feb 3 12:26:23 2010 +0200
+
+    brp-python-bytecompile fixes + improvements (RhBug:558997)
+    - fix incorrect paths (eg /site-packages/filename.py instead of
+      /usr/lib/pythonX.Y/site-packages/filename.py) ending up in bytecode
+    - add a "strict" mode where byte-compilation errors will abort the build
+    - when in non-strict mode, byte-compile everything we can instead of
+      bailing out at first error
+    - patch originally from Toshio Kuratomi, slightly changed to preserve
+      the original order of arguments to avoid unnecessary incompatibilities
+
+diff --git a/scripts/brp-python-bytecompile b/scripts/brp-python-bytecompile
+index 9fac5a7..79996ea 100644
+--- a/scripts/brp-python-bytecompile
++++ b/scripts/brp-python-bytecompile
+@@ -1,4 +1,5 @@
+ #!/bin/bash
++errors_terminate=$2
+ 
+ # If using normal root, avoid changing anything.
+ if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
+@@ -33,16 +34,25 @@ fi
+ # and below /usr/lib/python3.1/, we're targetting /usr/bin/python3.1
+ 
+ shopt -s nullglob
+-for python_libdir in $RPM_BUILD_ROOT/usr/lib*/python*/ ;
++for python_libdir in $RPM_BUILD_ROOT/usr/lib{,64}/python[0-9].[0-9]/ ;
+ do
+ 	python_binary=/usr/bin/$(basename $python_libdir)
++	real_libdir=${python_libdir/$RPM_BUILD_ROOT/}
+ 	echo "Bytecompiling .py files below $python_libdir using $python_binary"
+ 
+ 	# Generate normal (.pyc) byte-compiled files.
+-	$python_binary -c 'import compileall; compileall.compile_dir("'"$python_libdir"'", '"$depth"', "/", force=1, quiet=1)'
++	$python_binary -c 'import compileall, sys; sys.exit(not compileall.compile_dir("'"$python_libdir"'", '"$depth"', "'"$real_libdir"'", force=1, quiet=1))'
++	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_binary -O -c 'import compileall; compileall.compile_dir("'"$python_libdir"'", '"$depth"', "/", force=1, quiet=1)'
++	$python_binary -O -c 'import compileall, sys; sys.exit(not compileall.compile_dir("'"$python_libdir"'", '"$depth"', "'"$real_libdir"'", force=1, quiet=1))'
++	if [ $? -ne 0 -a 0$errors_terminate -ne 0 ]; then
++		# One or more of the files had a syntax error
++		exit 1
++	fi
+ done
+ 
+ 
+@@ -50,12 +60,16 @@ done
+ # implementation:
+ 
+ # Generate normal (.pyc) byte-compiled files.
+-$default_python -c 'import compileall, re, sys; sys.exit (not compileall.compile_dir("'"$RPM_BUILD_ROOT"'", '"$depth"', "/", 1, re.compile(r"'"/bin/|/sbin/|/usr/lib.*/python.+/"'"), quiet=1))'
+-if [ $? != 0 ]; then
++$default_python -c 'import compileall, re, sys; sys.exit (not compileall.compile_dir("'"$RPM_BUILD_ROOT"'", '"$depth"', "/", 1, re.compile(r"'"/bin/|/sbin/|/usr/lib(64)?/python[0-9]\.[0-9]"'"), quiet=1))'
++if [ $? -ne 0 -a 0$errors_terminate -ne 0 ]; then
+ 	# One or more of the files had a syntax error
+-	# XXX TODO: parametrize the exit code, only warn for now
+-	exit 0
++	exit 1
+ fi
+ 
+ # Generate optimized (.pyo) byte-compiled files.
+-$default_python -O -c 'import compileall, re; compileall.compile_dir("'"$RPM_BUILD_ROOT"'", '"$depth"', "/", 1, re.compile(r"'"/bin/|/sbin/|/usr/lib.*/python.+/"'"))' > /dev/null
++$default_python -O -c 'import compileall, re, sys; sys.exit(not compileall.compile_dir("'"$RPM_BUILD_ROOT"'", '"$depth"', "/", 1, re.compile(r"'"/bin/|/sbin/|/usr/lib(64)?/python[0-9]\.[0-9]"'"), quiet=1))' > /dev/null
++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

diff --git a/rpm.spec b/rpm.spec
index 9680970..5bb19cd 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -21,7 +21,7 @@
 Summary: The RPM package management system
 Name: rpm
 Version: %{rpmver}
-Release: 4%{?dist}
+Release: 5%{?dist}
 Group: System Environment/Base
 Url: http://www.rpm.org/
 Source0: http://rpm.org/releases/testing/%{name}-%{srcver}.tar.bz2
@@ -40,6 +40,7 @@ Patch3: rpm-4.7.90-fedora-specspo.patch
 Patch200: rpm-4.8.0-url-segfault.patch
 Patch201: rpm-4.8.0-verify-exitcode.patch
 Patch202: rpm-4.8.0-pythondeps-parallel.patch
+Patch203: rpm-4.8.0-python-bytecompile.patch
 
 # These are not yet upstream
 Patch301: rpm-4.6.0-niagara.patch
@@ -187,6 +188,7 @@ packages on a system.
 %patch200 -p1 -b .url-segfault
 %patch201 -p1 -b .verify-exitcode
 %patch202 -p1 -b .pythondeps-parallel
+%patch203 -p1 -b .python-bytecompile
 
 %patch301 -p1 -b .niagara
 %patch302 -p1 -b .geode
@@ -402,6 +404,9 @@ exit 0
 %doc doc/librpm/html/*
 
 %changelog
+* Wed Feb 03 2010 Panu Matilainen <pmatilai@redhat.com> - 4.8.0-5
+- python byte-compilation fixes + improvements (#558997)
+
 * Sat Jan 30 2010 Panu Matilainen <pmatilai@redhat.com> - 4.8.0-4
 - support parallel python versions in python dependency extractor (#532118)
 

                 reply	other threads:[~2026-11-23  9:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179542598471.1.5945582240852987074.rpms-rpm-2981a8197746@fedoraproject.org \
    --to=pmatilai@fedoraproject.org \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox