[PyQt] [PATCH] sort the glob results

Bernhard M. Wiedemann bernhardout at lsmod.de
Wed May 24 08:23:41 BST 2017


From: "Bernhard M. Wiedemann" <bmwiedemann+PyQt at suse.de>

because POSIX readdir does not guarantee any order
glob gave unexpectedly random results.

Some background:
for openSUSE Linux we build packages in the Open Build Service (OBS)
which tracks dependencies, so when e.g. a new glibc is submitted,
all packages depending on glibc are rebuilt
and if those depending binaries changed,
the new version is pushed to the mirrors.
And without this patch, the python-qt5 package would always differ.

See also https://reproducible-builds.org/ on that topic.

diff -ru PyQt5_gpl-5.8.2.orig/configure.py PyQt5_gpl-5.8.2/configure.py
--- PyQt5_gpl-5.8.2.orig/configure.py	2017-03-30 08:46:57.000000000 +0000
+++ PyQt5_gpl-5.8.2/configure.py	2017-05-22 17:38:59.779847576 +0000
@@ -1545,11 +1545,11 @@
             sp_qpy_dir = source_path('qpy', mname)
 
             qpy_c_sources = [os.path.relpath(f, mname)
-                    for f in glob.glob(os.path.join(sp_qpy_dir, '*.c'))]
+                    for f in sorted(glob.glob(os.path.join(sp_qpy_dir, '*.c')))]
             qpy_cpp_sources = [os.path.relpath(f, mname)
-                    for f in glob.glob(os.path.join(sp_qpy_dir, '*.cpp'))]
+                    for f in sorted(glob.glob(os.path.join(sp_qpy_dir, '*.cpp')))]
             qpy_headers = [os.path.relpath(f, mname)
-                    for f in glob.glob(os.path.join(sp_qpy_dir, '*.h'))]
+                    for f in sorted(glob.glob(os.path.join(sp_qpy_dir, '*.h')))]
 
             qpy_sources = qpy_c_sources + qpy_cpp_sources
         else:
@@ -1780,7 +1780,7 @@
 
     pro_lines = []
 
-    headers = [os.path.basename(f) for f in glob.glob('%s/*.h' % src_dir)]
+    headers = [os.path.basename(f) for f in sorted(glob.glob('%s/*.h' % src_dir))]
 
     if other_headers is not None:
         headers += other_headers
@@ -1788,9 +1788,9 @@
     if len(headers) != 0:
         pro_lines.append('HEADERS = %s' % ' '.join(headers))
 
-    sources = [os.path.basename(f) for f in glob.glob('%s/*.c' % src_dir)]
+    sources = [os.path.basename(f) for f in sorted(glob.glob('%s/*.c' % src_dir))]
 
-    for f in glob.glob('%s/*.cpp' % src_dir):
+    for f in sorted(glob.glob('%s/*.cpp' % src_dir)):
         f = os.path.basename(f)
 
         # Exclude any moc generated C++ files that might be around from a
@@ -1805,7 +1805,7 @@
         pro_lines.append('SOURCES = %s' % ' '.join(sources))
 
     objective_sources = [
-            os.path.basename(f) for f in glob.glob('%s/*.mm' % src_dir)]
+            os.path.basename(f) for f in sorted(glob.glob('%s/*.mm' % src_dir))]
 
     if len(objective_sources) != 0:
         pro_lines.append('OBJECTIVE_SOURCES = %s' % ' '.join(objective_sources))
@@ -2580,7 +2580,7 @@
 
     if target_config.pyqt_sip_dir:
         sip_files = [os.path.relpath(f, mname)
-                for f in glob.glob(source_path('sip', mname, '*.sip'))]
+                for f in sorted(glob.glob(source_path('sip', mname, '*.sip')))]
         if len(sip_files) != 0:
             pro_lines.append('sip.path = %s' % qmake_quote(target_config.pyqt_sip_dir + '/' + mname))
             pro_lines.append('sip.files = %s' % ' '.join(sip_files))


More information about the PyQt mailing list