diff options
author | Colin Putney <colin.putney@vannevarlabs.com> | 2024-03-21 19:22:45 -0600 |
---|---|---|
committer | Colin Putney <colin.putney@vannevarlabs.com> | 2024-03-21 19:27:06 -0600 |
commit | 96118850f323f41c163f1f5a8231128879fb2f2e (patch) | |
tree | e642d305d3dca24c0758196295382373c4618142 /pkgs/development/interpreters | |
parent | 234bb31f611f43f8b744b305ab82035de637aaca (diff) |
Unwrap python scripts when building an environment
When building a python environment's bin directory, we now detect wrapped python scripts from installed packages, and generate unwrapped copies with the environment's python executable as the interpreter.
Diffstat (limited to 'pkgs/development/interpreters')
-rw-r--r-- | pkgs/development/interpreters/python/wrapper.nix | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/pkgs/development/interpreters/python/wrapper.nix b/pkgs/development/interpreters/python/wrapper.nix index f5f9b03e0fd3c..aa568a01b1b0c 100644 --- a/pkgs/development/interpreters/python/wrapper.nix +++ b/pkgs/development/interpreters/python/wrapper.nix @@ -35,6 +35,8 @@ let fi mkdir -p "$out/bin" + rm -f $out/bin/.*-wrapped + for path in ${lib.concatStringsSep " " paths}; do if [ -d "$path/bin" ]; then cd "$path/bin" @@ -42,7 +44,13 @@ let if [ -f "$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 [ -f ".$prg-wrapped" ]; then + echo "#!${pythonExecutable}" > "$out/bin/$prg" + sed -e '1d' -e '3d' ".$prg-wrapped" >> "$out/bin/$prg" + chmod +x "$out/bin/$prg" + else + makeWrapper "$path/bin/$prg" "$out/bin/$prg" --inherit-argv0 --resolve-argv0 ${lib.optionalString (!permitUserSite) ''--set PYTHONNOUSERSITE "true"''} ${lib.concatStringsSep " " makeWrapperArgs} + fi fi fi done |