@ -21,6 +21,7 @@
, sourceVersion
, sha256
, passthruFun
, bash
} :
assert x11Support -> tcl != null
@ -46,7 +47,8 @@ let
nativeBuildInputs = [
nukeReferences
] ++ optionals ( stdenv . hostPlatform != stdenv . buildPlatform ) [
buildPackages . stdenv . cc crossPython
buildPackages . stdenv . cc
pythonForBuild
] ;
buildInputs = filter ( p : p != null ) [
@ -56,11 +58,11 @@ let
hasDistutilsCxxPatch = ! ( stdenv . cc . isGNU or false ) ;
crossPython = buildPackages . ${ " p y t h o n ${ sourceVersion . major } ${ sourceVersion . minor } " } ;
pythonForBuild = buildPackages . ${ " p y t h o n ${ sourceVersion . major } ${ sourceVersion . minor } " } ;
pythonForBuild = if stdenv . hostPlatform == stdenv . buildPlatform then
pythonForBuildInterpreter = if stdenv . hostPlatform == stdenv . buildPlatform then
" $ o u t / b i n / p y t h o n "
else crossPython . interpreter ;
else pythonForBuild . interpreter ;
in with passthru ; stdenv . mkDerivation {
pname = " p y t h o n 3 " ;
@ -215,14 +217,25 @@ in with passthru; stdenv.mkDerivation {
# We rebuild three times, once for each optimization level
# Python 3.7 implements PEP 552, introducing support for deterministic bytecode.
# This is automatically used when `SOURCE_DATE_EPOCH` is set.
find $ out - name " * . p y " | $ { pythonForBuild } - m compileall - q - f - x " l i b 2 t o 3 " - i -
find $ out - name " * . p y " | $ { pythonForBuild } - O - m compileall - q - f - x " l i b 2 t o 3 " - i -
find $ out - name " * . p y " | $ { pythonForBuild } - OO - m compileall - q - f - x " l i b 2 t o 3 " - i -
find $ out - name " * . p y " | $ { pythonForBuildInterpreter } - m compileall - q - f - x " l i b 2 t o 3 " - i -
find $ out - name " * . p y " | $ { pythonForBuildInterpreter } - O - m compileall - q - f - x " l i b 2 t o 3 " - i -
find $ out - name " * . p y " | $ { pythonForBuildInterpreter } - OO - m compileall - q - f - x " l i b 2 t o 3 " - i -
'' ;
preFixup = stdenv . lib . optionalString ( stdenv . hostPlatform != stdenv . buildPlatform ) ''
# Ensure patch-shebangs uses shebangs of host interpreter.
export PATH = $ { stdenv . lib . makeBinPath [ " $ o u t " bash ] }: $ PATH
'' ;
# Enforce that we don't have references to the OpenSSL -dev package, which we
# explicitly specify in our configure flags above.
disallowedReferences = [ openssl . dev ] ;
disallowedReferences = [
openssl . dev
] ++ stdenv . lib . optionals ( stdenv . hostPlatform != stdenv . buildPlatform ) [
# Ensure we don't have references to build-time packages.
# These typically end up in shebangs.
pythonForBuild buildPackages . bash
] ;
inherit passthru ;