Skip to content

Commit 479b386

Browse files
bmwiedemannwebsurfer5
authored andcommitted
bpo-36302: Sort list of sources (pythonGH-12341)
When building packages (e.g. for openSUSE Linux) (random) filesystem order of input files influences ordering of functions in the output .so files. Thus without the patch, builds (in disposable VMs) would usually differ. Without this patch, all callers have to be patched individually ofalk/libdnet#42 sass/libsass-python#212 tahoe-lafs/pycryptopp#41 yt-project/yt#2206 pyproj4/pyproj#142 pytries/datrie#49 Roche/pyreadstat#37 but that is an infinite effort. See https://reproducible-builds.org/ for why this matters.
1 parent 79c5acc commit 479b386

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Lib/distutils/command/build_ext.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,8 @@ def build_extension(self, ext):
490490
"in 'ext_modules' option (extension '%s'), "
491491
"'sources' must be present and must be "
492492
"a list of source filenames" % ext.name)
493-
sources = list(sources)
493+
# sort to make the resulting .so file build reproducible
494+
sources = sorted(sources)
494495

495496
ext_path = self.get_ext_fullpath(ext.name)
496497
depends = sources + ext.depends
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
distutils sorts source file lists so that Extension .so files
2+
build more reproducibly by default

0 commit comments

Comments
 (0)