Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions pkgs/development/interpreters/python/wrapper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
lib,
stdenv,
buildEnv,
runCommand,
makeBinaryWrapper,

# manually pased
Expand All @@ -22,7 +23,11 @@
let
env =
let
paths = requiredPythonModules (extraLibs ++ [ python ]);
paths = requiredPythonModules (extraLibs ++ [ python ]) ++ [
(runCommand "bin" { } ''
mkdir -p $out/bin
'')
];
pythonPath = "${placeholder "out"}/${python.sitePackages}";
pythonExecutable = "${placeholder "out"}/bin/${python.executable}";
in
Expand All @@ -36,21 +41,26 @@ let
nativeBuildInputs = [ makeBinaryWrapper ];

postBuild = ''
if [ -L "$out/bin" ]; then
unlink "$out/bin"
fi
mkdir -p "$out/bin"

for path in ${lib.concatStringsSep " " paths}; do
if [ -d "$path/bin" ]; then
cd "$path/bin"
for prg in *; do
if [ -f "$prg" ]; then
if [ -f "$prg" ] && [ -x "$prg" ]; then
rm -f "$out/bin/$prg"
if [ -x "$prg" ]; then
makeWrapper "$path/bin/$prg" "$out/bin/$prg" --set NIX_PYTHONPREFIX "$out" --set NIX_PYTHONEXECUTABLE ${pythonExecutable} --set NIX_PYTHONPATH ${pythonPath} ${
lib.optionalString (!permitUserSite) ''--set PYTHONNOUSERSITE "true"''
} ${lib.concatStringsSep " " makeWrapperArgs}
if [ "$prg" = "${python.executable}" ]; then
makeWrapper "${python.interpreter}" "$out/bin/$prg" \
--inherit-argv0 \
${lib.optionalString (!permitUserSite) ''--set PYTHONNOUSERSITE "true"''} \
${lib.concatStringsSep " " makeWrapperArgs}
elif [ "$(readlink "$prg")" = "${python.executable}" ]; then
ln -s "${python.executable}" "$out/bin/$prg"
else
makeWrapper "$path/bin/$prg" "$out/bin/$prg" \
--set NIX_PYTHONPREFIX "$out" \
--set NIX_PYTHONEXECUTABLE ${pythonExecutable} \
--set NIX_PYTHONPATH ${pythonPath} \
${lib.optionalString (!permitUserSite) ''--set PYTHONNOUSERSITE "true"''} \
${lib.concatStringsSep " " makeWrapperArgs}
fi
fi
done
Expand Down
Loading