The Python interpreters are patched so they can build .pyc bytecode free of certain indeterminism. When building Python packages we currently set ``` compiling python files. in nix store. DETERMINISTIC_BUILD=1; PYTHONHASHSEED = 0; ``` Instead if setting these environment variables in the function that builds the package, this commit sets the variables instead in the Python setup hook. That way, whenever Python is included in a derivation, these variables are set. See also the issue https://github.com/NixOS/nixpkgs/issues/25707.wip/yesman
parent
5aa530f2a8
commit
acd32a4caf
@ -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) |
@ -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) |
@ -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) |
@ -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) |
@ -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) |
@ -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) |
@ -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 |
||||
'' |
@ -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; |
Loading…
Reference in new issue