Skip to content

Commit 1a48906

Browse files
committed
pkgs/_bootstrap/python: assorted reproducibility fixes
1 parent 205087e commit 1a48906

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

pkgs/_bootstrap/python.nix

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,38 @@ in
2626
mv Lib/compileall.py Lib/compileall.py.bak
2727
echo 'import sys; sys.exit(0)' > Lib/compileall.py
2828
chmod +x Lib/compileall.py
29-
sed -i 's|__FILE__|"__FILE__"|' \
29+
sed -i 's|__FILE__|__FILE_NAME__|' \
3030
Python/errors.c \
3131
Include/pyerrors.h \
3232
Include/cpython/object.h \
3333
Modules/pyexpat.c
34+
sed -i 's|TIME __TIME__|TIME "xx:xx:xx"|' Modules/getbuildinfo.c
35+
sed -i 's|DATE __DATE__|DATE "xx/xx/xx"|' Modules/getbuildinfo.c
36+
# different build path length leads to different wrapping. avoid
37+
sed -i 's|vars, stream=f|vars, stream=f, width=2**24|' Lib/sysconfig.py
3438
# configure:
3539
ash configure \
40+
ac_cv_broken_sem_getvalue=yes \
41+
ac_cv_posix_semaphores_enabled=no \
42+
OPT='-DNDEBUG -fwrapv -O3 -Wall' \
3643
--without-static-libpython \
3744
--build x86_64-linux-musl \
3845
--prefix=$out \
3946
--enable-shared \
4047
--with-ensurepip=no
48+
# ensure reproducibility in case of no /dev/shm
49+
grep 'define POSIX_SEMAPHORES_NOT_ENABLED 1' pyconfig.h
50+
grep 'define HAVE_BROKEN_SEM_GETVALUE 1' pyconfig.h
4151
# build:
4252
make SHELL=$SHELL -j $NPROC CFLAGS="-ffile-prefix-map=$(pwd)=/builddir/"
4353
# install:
4454
make SHELL=$SHELL -j $NPROC install
4555
# restore compileall just in case
4656
cat Lib/compileall.py.bak > $out/lib/python3.11/compileall.py
47-
# strip builddir mentions
48-
sed -i "s|$(pwd)|...|" \
57+
# strip builddir mentions:
58+
sed -i "s|$(pwd)|...|g" \
4959
$out/lib/python3.*/_sysconfigdata__*.py \
50-
$out/lib/python3.*/config-3.11-x86_64-linux-musl/Makefile
60+
$out/lib/python3.*/config-3.*-x86_64-linux-musl/Makefile
5161
# check for build path leaks:
5262
( ! grep -rF $(pwd) $out )
5363
'';

0 commit comments

Comments
 (0)