Skip to content

Commit ca04974

Browse files
committed
bpo-36302: Sort list of sources
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 f35c51d commit ca04974

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)