Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at release-19.03 63 lines 1.7 kB view raw
1{ stdenv, python, buildEnv, makeWrapper 2, extraLibs ? [] 3, extraOutputsToInstall ? [] 4, postBuild ? "" 5, ignoreCollisions ? false 6, requiredPythonModules 7# Wrap executables with the given argument. 8, makeWrapperArgs ? [] 9, }: 10 11# Create a python executable that knows about additional packages. 12let 13 env = let 14 paths = requiredPythonModules (extraLibs ++ [ python ] ) ; 15 in buildEnv { 16 name = "${python.name}-env"; 17 18 inherit paths; 19 inherit ignoreCollisions; 20 extraOutputsToInstall = [ "out" ] ++ extraOutputsToInstall; 21 22 postBuild = '' 23 . "${makeWrapper}/nix-support/setup-hook" 24 25 if [ -L "$out/bin" ]; then 26 unlink "$out/bin" 27 fi 28 mkdir -p "$out/bin" 29 30 for path in ${stdenv.lib.concatStringsSep " " paths}; do 31 if [ -d "$path/bin" ]; then 32 cd "$path/bin" 33 for prg in *; do 34 if [ -f "$prg" ]; then 35 rm -f "$out/bin/$prg" 36 if [ -x "$prg" ]; then 37 makeWrapper "$path/bin/$prg" "$out/bin/$prg" --set PYTHONHOME "$out" --set PYTHONNOUSERSITE "true" ${stdenv.lib.concatStringsSep " " makeWrapperArgs} 38 fi 39 fi 40 done 41 fi 42 done 43 '' + postBuild; 44 45 inherit (python) meta; 46 47 passthru = python.passthru // { 48 interpreter = "${env}/bin/${python.executable}"; 49 inherit python; 50 env = stdenv.mkDerivation { 51 name = "interactive-${python.name}-environment"; 52 nativeBuildInputs = [ env ]; 53 54 buildCommand = '' 55 echo >&2 "" 56 echo >&2 "*** Python 'env' attributes are intended for interactive nix-shell sessions, not for building! ***" 57 echo >&2 "" 58 exit 1 59 ''; 60 }; 61 }; 62 }; 63in env