Merge pull request #25916 from FRidh/reproducible
Python: set DETERMINISTIC_BUILD and PYTHONHASHSEED in setupHook
This commit is contained in:
commit
1267b155c4
@ -15,6 +15,7 @@
|
|||||||
, expat
|
, expat
|
||||||
, libffi
|
, libffi
|
||||||
, CF, configd, coreutils
|
, CF, configd, coreutils
|
||||||
|
, python-setup-hook
|
||||||
# For the Python package set
|
# For the Python package set
|
||||||
, pkgs, packageOverrides ? (self: super: {})
|
, pkgs, packageOverrides ? (self: super: {})
|
||||||
}:
|
}:
|
||||||
@ -150,7 +151,7 @@ in stdenv.mkDerivation {
|
|||||||
NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin "-msse2";
|
NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin "-msse2";
|
||||||
DETERMINISTIC_BUILD = 1;
|
DETERMINISTIC_BUILD = 1;
|
||||||
|
|
||||||
setupHook = ./setup-hook.sh;
|
setupHook = python-setup-hook sitePackages;
|
||||||
|
|
||||||
postPatch = optionalString (x11Support && (tix != null)) ''
|
postPatch = optionalString (x11Support && (tix != null)) ''
|
||||||
substituteInPlace "Lib/lib-tk/Tix.py" --replace "os.environ.get('TIX_LIBRARY')" "os.environ.get('TIX_LIBRARY') or '${tix}/lib'"
|
substituteInPlace "Lib/lib-tk/Tix.py" --replace "os.environ.get('TIX_LIBRARY')" "os.environ.get('TIX_LIBRARY') or '${tix}/lib'"
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
addPythonPath() {
|
|
||||||
addToSearchPathWithCustomDelimiter : PYTHONPATH $1/lib/python2.7/site-packages
|
|
||||||
}
|
|
||||||
|
|
||||||
toPythonPath() {
|
|
||||||
local paths="$1"
|
|
||||||
local result=
|
|
||||||
for i in $paths; do
|
|
||||||
p="$i/lib/python2.7/site-packages"
|
|
||||||
result="${result}${result:+:}$p"
|
|
||||||
done
|
|
||||||
echo $result
|
|
||||||
}
|
|
||||||
|
|
||||||
envHooks+=(addPythonPath)
|
|
@ -77,7 +77,7 @@ in stdenv.mkDerivation {
|
|||||||
)
|
)
|
||||||
'';
|
'';
|
||||||
|
|
||||||
setupHook = ./setup-hook.sh;
|
setupHook = python-setup-hook sitePackages;
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
# needed for some packages, especially packages that backport functionality
|
# needed for some packages, especially packages that backport functionality
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
addPythonPath() {
|
|
||||||
addToSearchPathWithCustomDelimiter : PYTHONPATH $1/lib/python3.3/site-packages
|
|
||||||
}
|
|
||||||
|
|
||||||
toPythonPath() {
|
|
||||||
local paths="$1"
|
|
||||||
local result=
|
|
||||||
for i in $paths; do
|
|
||||||
p="$i/lib/python3.3/site-packages"
|
|
||||||
result="${result}${result:+:}$p"
|
|
||||||
done
|
|
||||||
echo $result
|
|
||||||
}
|
|
||||||
|
|
||||||
envHooks+=(addPythonPath)
|
|
@ -13,6 +13,7 @@
|
|||||||
, callPackage
|
, callPackage
|
||||||
, self
|
, self
|
||||||
, CF, configd
|
, CF, configd
|
||||||
|
, python-setup-hook
|
||||||
# For the Python package set
|
# For the Python package set
|
||||||
, pkgs, packageOverrides ? (self: super: {})
|
, pkgs, packageOverrides ? (self: super: {})
|
||||||
}:
|
}:
|
||||||
@ -100,7 +101,7 @@ in stdenv.mkDerivation {
|
|||||||
''}
|
''}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
setupHook = ./setup-hook.sh;
|
setupHook = python-setup-hook sitePackages;
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
# needed for some packages, especially packages that backport functionality
|
# needed for some packages, especially packages that backport functionality
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
addPythonPath() {
|
|
||||||
addToSearchPathWithCustomDelimiter : PYTHONPATH $1/lib/python3.4/site-packages
|
|
||||||
}
|
|
||||||
|
|
||||||
toPythonPath() {
|
|
||||||
local paths="$1"
|
|
||||||
local result=
|
|
||||||
for i in $paths; do
|
|
||||||
p="$i/lib/python3.4/site-packages"
|
|
||||||
result="${result}${result:+:}$p"
|
|
||||||
done
|
|
||||||
echo $result
|
|
||||||
}
|
|
||||||
|
|
||||||
envHooks+=(addPythonPath)
|
|
@ -13,6 +13,7 @@
|
|||||||
, callPackage
|
, callPackage
|
||||||
, self
|
, self
|
||||||
, CF, configd
|
, CF, configd
|
||||||
|
, python-setup-hook
|
||||||
# For the Python package set
|
# For the Python package set
|
||||||
, pkgs, packageOverrides ? (self: super: {})
|
, pkgs, packageOverrides ? (self: super: {})
|
||||||
}:
|
}:
|
||||||
@ -102,7 +103,7 @@ in stdenv.mkDerivation {
|
|||||||
''}
|
''}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
setupHook = ./setup-hook.sh;
|
setupHook = python-setup-hook sitePackages;
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
# needed for some packages, especially packages that backport functionality
|
# needed for some packages, especially packages that backport functionality
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
addPythonPath() {
|
|
||||||
addToSearchPathWithCustomDelimiter : PYTHONPATH $1/lib/python3.5/site-packages
|
|
||||||
}
|
|
||||||
|
|
||||||
toPythonPath() {
|
|
||||||
local paths="$1"
|
|
||||||
local result=
|
|
||||||
for i in $paths; do
|
|
||||||
p="$i/lib/python3.5/site-packages"
|
|
||||||
result="${result}${result:+:}$p"
|
|
||||||
done
|
|
||||||
echo $result
|
|
||||||
}
|
|
||||||
|
|
||||||
envHooks+=(addPythonPath)
|
|
@ -14,6 +14,7 @@
|
|||||||
, callPackage
|
, callPackage
|
||||||
, self
|
, self
|
||||||
, CF, configd
|
, CF, configd
|
||||||
|
, python-setup-hook
|
||||||
# For the Python package set
|
# For the Python package set
|
||||||
, pkgs, packageOverrides ? (self: super: {})
|
, pkgs, packageOverrides ? (self: super: {})
|
||||||
}:
|
}:
|
||||||
@ -94,7 +95,7 @@ in stdenv.mkDerivation {
|
|||||||
''}
|
''}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
setupHook = ./setup-hook.sh;
|
setupHook = python-setup-hook sitePackages;
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
# needed for some packages, especially packages that backport functionality
|
# needed for some packages, especially packages that backport functionality
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
addPythonPath() {
|
|
||||||
addToSearchPathWithCustomDelimiter : PYTHONPATH $1/lib/python3.6/site-packages
|
|
||||||
}
|
|
||||||
|
|
||||||
toPythonPath() {
|
|
||||||
local paths="$1"
|
|
||||||
local result=
|
|
||||||
for i in $paths; do
|
|
||||||
p="$i/lib/python3.6/site-packages"
|
|
||||||
result="${result}${result:+:}$p"
|
|
||||||
done
|
|
||||||
echo $result
|
|
||||||
}
|
|
||||||
|
|
||||||
envHooks+=(addPythonPath)
|
|
@ -57,13 +57,6 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled"] // {
|
|||||||
|
|
||||||
inherit pythonPath;
|
inherit pythonPath;
|
||||||
|
|
||||||
|
|
||||||
# Determinism: The interpreter is patched to write null timestamps when compiling python files.
|
|
||||||
# This way python doesn't try to update them when we freeze timestamps in nix store.
|
|
||||||
DETERMINISTIC_BUILD=1;
|
|
||||||
# Determinism: We fix the hashes of str, bytes and datetime objects.
|
|
||||||
PYTHONHASHSEED = 0;
|
|
||||||
|
|
||||||
buildInputs = [ wrapPython ] ++ buildInputs ++ pythonPath
|
buildInputs = [ wrapPython ] ++ buildInputs ++ pythonPath
|
||||||
++ [ (ensureNewerSourcesHook { year = "1980"; }) ]
|
++ [ (ensureNewerSourcesHook { year = "1980"; }) ]
|
||||||
++ (lib.optional (lib.hasSuffix "zip" attrs.src.name or "") unzip)
|
++ (lib.optional (lib.hasSuffix "zip" attrs.src.name or "") unzip)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{ stdenv, fetchurl, zlib ? null, zlibSupport ? true, bzip2, pkgconfig, libffi
|
{ stdenv, fetchurl, zlib ? null, zlibSupport ? true, bzip2, pkgconfig, libffi
|
||||||
, sqlite, openssl, ncurses, python, expat, tcl, tk, tix, xlibsWrapper, libX11
|
, sqlite, openssl, ncurses, python, expat, tcl, tk, tix, xlibsWrapper, libX11
|
||||||
, makeWrapper, callPackage, self, gdbm, db
|
, makeWrapper, callPackage, self, gdbm, db
|
||||||
|
, python-setup-hook
|
||||||
# For the Python package set
|
# For the Python package set
|
||||||
, pkgs, packageOverrides ? (self: super: {})
|
, pkgs, packageOverrides ? (self: super: {})
|
||||||
}:
|
}:
|
||||||
@ -14,6 +15,7 @@ let
|
|||||||
pythonVersion = "2.7";
|
pythonVersion = "2.7";
|
||||||
version = "${majorVersion}.${minorVersion}${minorVersionSuffix}";
|
version = "${majorVersion}.${minorVersion}${minorVersionSuffix}";
|
||||||
libPrefix = "pypy${majorVersion}";
|
libPrefix = "pypy${majorVersion}";
|
||||||
|
sitePackages = "site-packages";
|
||||||
|
|
||||||
in stdenv.mkDerivation rec {
|
in stdenv.mkDerivation rec {
|
||||||
name = "pypy-${version}";
|
name = "pypy-${version}";
|
||||||
@ -67,7 +69,7 @@ in stdenv.mkDerivation rec {
|
|||||||
${python.interpreter} rpython/bin/rpython --make-jobs="$NIX_BUILD_CORES" -Ojit --batch pypy/goal/targetpypystandalone.py --withmod-_minimal_curses --withmod-unicodedata --withmod-thread --withmod-bz2 --withmod-_multiprocessing
|
${python.interpreter} rpython/bin/rpython --make-jobs="$NIX_BUILD_CORES" -Ojit --batch pypy/goal/targetpypystandalone.py --withmod-_minimal_curses --withmod-unicodedata --withmod-thread --withmod-bz2 --withmod-_multiprocessing
|
||||||
'';
|
'';
|
||||||
|
|
||||||
setupHook = ./setup-hook.sh;
|
setupHook = python-setup-hook sitePackages;
|
||||||
|
|
||||||
postBuild = ''
|
postBuild = ''
|
||||||
cd ./lib_pypy
|
cd ./lib_pypy
|
||||||
@ -125,12 +127,11 @@ in stdenv.mkDerivation rec {
|
|||||||
passthru = let
|
passthru = let
|
||||||
pythonPackages = callPackage ../../../../../top-level/python-packages.nix {python=self; overrides=packageOverrides;};
|
pythonPackages = callPackage ../../../../../top-level/python-packages.nix {python=self; overrides=packageOverrides;};
|
||||||
in rec {
|
in rec {
|
||||||
inherit zlibSupport libPrefix;
|
inherit zlibSupport libPrefix sitePackages;
|
||||||
executable = "pypy";
|
executable = "pypy";
|
||||||
isPypy = true;
|
isPypy = true;
|
||||||
buildEnv = callPackage ../../wrapper.nix { python = self; };
|
buildEnv = callPackage ../../wrapper.nix { python = self; };
|
||||||
interpreter = "${self}/bin/${executable}";
|
interpreter = "${self}/bin/${executable}";
|
||||||
sitePackages = "site-packages";
|
|
||||||
withPackages = import ../../with-packages.nix { inherit buildEnv pythonPackages;};
|
withPackages = import ../../with-packages.nix { inherit buildEnv pythonPackages;};
|
||||||
pkgs = pythonPackages;
|
pkgs = pythonPackages;
|
||||||
};
|
};
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
addPythonPath() {
|
|
||||||
addToSearchPathWithCustomDelimiter : PYTHONPATH $1/site-packages
|
|
||||||
}
|
|
||||||
|
|
||||||
toPythonPath() {
|
|
||||||
local paths="$1"
|
|
||||||
local result=
|
|
||||||
for i in $paths; do
|
|
||||||
p="$i/site-packages"
|
|
||||||
result="${result}${result:+:}$p"
|
|
||||||
done
|
|
||||||
echo $result
|
|
||||||
}
|
|
||||||
|
|
||||||
envHooks+=(addPythonPath)
|
|
13
pkgs/development/interpreters/python/setup-hook.nix
Normal file
13
pkgs/development/interpreters/python/setup-hook.nix
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{ runCommand }:
|
||||||
|
|
||||||
|
sitePackages:
|
||||||
|
|
||||||
|
let
|
||||||
|
hook = ./setup-hook.sh;
|
||||||
|
in runCommand "python-setup-hook.sh" {
|
||||||
|
inherit sitePackages;
|
||||||
|
} ''
|
||||||
|
cp ${hook} hook.sh
|
||||||
|
substituteAllInPlace hook.sh
|
||||||
|
mv hook.sh $out
|
||||||
|
''
|
21
pkgs/development/interpreters/python/setup-hook.sh
Normal file
21
pkgs/development/interpreters/python/setup-hook.sh
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
addPythonPath() {
|
||||||
|
addToSearchPathWithCustomDelimiter : PYTHONPATH $1/@sitePackages@
|
||||||
|
}
|
||||||
|
|
||||||
|
toPythonPath() {
|
||||||
|
local paths="$1"
|
||||||
|
local result=
|
||||||
|
for i in $paths; do
|
||||||
|
p="$i/@sitePackages@"
|
||||||
|
result="${result}${result:+:}$p"
|
||||||
|
done
|
||||||
|
echo $result
|
||||||
|
}
|
||||||
|
|
||||||
|
envHooks+=(addPythonPath)
|
||||||
|
|
||||||
|
# Determinism: The interpreter is patched to write null timestamps when compiling python files.
|
||||||
|
# This way python doesn't try to update them when we freeze timestamps in nix store.
|
||||||
|
export DETERMINISTIC_BUILD=1;
|
||||||
|
# Determinism: We fix the hashes of str, bytes and datetime objects.
|
||||||
|
export PYTHONHASHSEED=0;
|
@ -6207,6 +6207,9 @@ with pkgs;
|
|||||||
self = python36;
|
self = python36;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Should eventually be moved inside Python interpreters.
|
||||||
|
python-setup-hook = callPackage ../development/interpreters/python/setup-hook.nix { };
|
||||||
|
|
||||||
pypy = pypy27;
|
pypy = pypy27;
|
||||||
|
|
||||||
pypy27 = callPackage ../development/interpreters/python/pypy/2.7 {
|
pypy27 = callPackage ../development/interpreters/python/pypy/2.7 {
|
||||||
|
Loading…
Reference in New Issue
Block a user