diff options
author | bb010g <me@bb010g.com> | 2019-04-17 13:03:57 -0700 |
---|---|---|
committer | Frederik Rietdijk <freddyrietdijk@fridh.nl> | 2019-04-18 08:12:29 +0200 |
commit | 28ac30930934a5a0f40b6c585bc967ae3bbbd348 (patch) | |
tree | 0c35478659e12d65fc862c3bfd1ed32e202f7864 /pkgs/development/interpreters/python/cpython | |
parent | e53ade7dab1fa5cf4ff7c37ad279802ee1dce863 (diff) | |
download | nixlib-28ac30930934a5a0f40b6c585bc967ae3bbbd348.tar nixlib-28ac30930934a5a0f40b6c585bc967ae3bbbd348.tar.gz nixlib-28ac30930934a5a0f40b6c585bc967ae3bbbd348.tar.bz2 nixlib-28ac30930934a5a0f40b6c585bc967ae3bbbd348.tar.lz nixlib-28ac30930934a5a0f40b6c585bc967ae3bbbd348.tar.xz nixlib-28ac30930934a5a0f40b6c585bc967ae3bbbd348.tar.zst nixlib-28ac30930934a5a0f40b6c585bc967ae3bbbd348.zip |
python3{5,6}: Reintroduce bytecode determinism
Originally introduced in 8970a9c and 1531b5e, these patches were lost in efbe87f when the CPython version files were merged, likely due to CPython 3.7 not needing them anymore. These patches should remain in-tree until CPython 3.5 and 3.6 support is dropped completely. Found with the diffoscope ( https://diffoscope.org/ ).
Diffstat (limited to 'pkgs/development/interpreters/python/cpython')
-rw-r--r-- | pkgs/development/interpreters/python/cpython/3.5/force_bytecode_determinism.patch | 17 | ||||
-rw-r--r-- | pkgs/development/interpreters/python/cpython/default.nix | 7 |
2 files changed, 22 insertions, 2 deletions
diff --git a/pkgs/development/interpreters/python/cpython/3.5/force_bytecode_determinism.patch b/pkgs/development/interpreters/python/cpython/3.5/force_bytecode_determinism.patch new file mode 100644 index 000000000000..c263cdbff4db --- /dev/null +++ b/pkgs/development/interpreters/python/cpython/3.5/force_bytecode_determinism.patch @@ -0,0 +1,17 @@ +--- a/Lib/py_compile.py ++++ b/Lib/py_compile.py +@@ -139,3 +139,4 @@ + source_stats = loader.path_stats(file) ++ source_mtime = 1 if 'DETERMINISTIC_BUILD' in os.environ else source_stats['mtime'] + bytecode = importlib._bootstrap_external._code_to_bytecode( +- code, source_stats['mtime'], source_stats['size']) ++ code, source_mtime, source_stats['size']) +--- a/Lib/importlib/_bootstrap_external.py ++++ b/Lib/importlib/_bootstrap_external.py +@@ -485,5 +485,5 @@ + if source_stats is not None: + try: +- source_mtime = int(source_stats['mtime']) ++ source_mtime = 1 + except KeyError: + pass diff --git a/pkgs/development/interpreters/python/cpython/default.nix b/pkgs/development/interpreters/python/cpython/default.nix index 64021672276d..7d90e201d192 100644 --- a/pkgs/development/interpreters/python/cpython/default.nix +++ b/pkgs/development/interpreters/python/cpython/default.nix @@ -87,6 +87,9 @@ in with passthru; stdenv.mkDerivation { # (since it will do a futile invocation of gcc (!) to find # libuuid, slowing down program startup a lot). (./. + "/${sourceVersion.major}.${sourceVersion.minor}/no-ldconfig.patch") + ] ++ optionals (isPy35 || isPy36) [ + # Determinism: Write null timestamps when compiling python files. + ./3.5/force_bytecode_determinism.patch ] ++ optionals isPy35 [ # Backports support for LD_LIBRARY_PATH from 3.6 ./3.5/ld_library_path.patch @@ -168,8 +171,8 @@ in with passthru; stdenv.mkDerivation { export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -msse2" export MACOSX_DEPLOYMENT_TARGET=10.6 '' + optionalString (isPy3k && pythonOlder "3.7") '' - # Determinism: The interpreter is patched to write null timestamps when compiling python files. - # This way python does not try to update them when we freeze timestamps in nix store. + # Determinism: The interpreter is patched to write null timestamps when compiling Python files + # so Python doesn't try to update the bytecode when seeing frozen timestamps in Nix's store. export DETERMINISTIC_BUILD=1; '' + optionalString stdenv.hostPlatform.isMusl '' export NIX_CFLAGS_COMPILE+=" -DTHREAD_STACK_SIZE=0x100000" |