summary refs log tree commit diff
path: root/pkgs/development/interpreters/python/wrap.sh
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2019-12-29 18:12:51 +0100
committerFrederik Rietdijk <fridh@fridh.nl>2019-12-30 16:46:55 +0100
commitf4e74edd8c14f82f5e145f5b7d29e64d39f1e0aa (patch)
tree9fa4c4fb162123f027409c7816392486d46ac43a /pkgs/development/interpreters/python/wrap.sh
parentdc8444005526cdbaa86ba71f724ae29f4540c2e3 (diff)
downloadnixpkgs-f4e74edd8c14f82f5e145f5b7d29e64d39f1e0aa.tar
nixpkgs-f4e74edd8c14f82f5e145f5b7d29e64d39f1e0aa.tar.gz
nixpkgs-f4e74edd8c14f82f5e145f5b7d29e64d39f1e0aa.tar.bz2
nixpkgs-f4e74edd8c14f82f5e145f5b7d29e64d39f1e0aa.tar.lz
nixpkgs-f4e74edd8c14f82f5e145f5b7d29e64d39f1e0aa.tar.xz
nixpkgs-f4e74edd8c14f82f5e145f5b7d29e64d39f1e0aa.tar.zst
nixpkgs-f4e74edd8c14f82f5e145f5b7d29e64d39f1e0aa.zip
python.pkgs.wrapPython: get rid of warning
When `makeWrapperArgs` variable is not set, `declare -p makeWrapperArgs`
will return with 1 and print an error message to stderr.

I did not handle the non-existence case in b0633406cb70e0e4ae3470a6b49e32b38d99ac16
because I thought `mk-python-derivation` will always define `makeWrapperArgs`
but `wrapProgram` can be called independently. And even with `mk-python-derivation`,
`makeWrappers` will not be set unless explicitly declared in the derivation
because of https://github.com/NixOS/nix/issues/1461.

I was lead to believe that because the builds were succeeding and I confirmed
that the mechanism fails when the variable is not defined and `-o nounset` is enabled.
It appears that `wrapPython` setup hook is not running under `-o nounset`, though,
invaldating the assumption.

Now we are checking that the variable exists before checking its type, which
will get rid of the warning and also prevent future error when `-o nounset`
is enabled in the setup hook.

For more information, see the discussion at
https://github.com/NixOS/nixpkgs/commit/a6bb2ede232940a96150da7207a3ecd15eb6328
Diffstat (limited to 'pkgs/development/interpreters/python/wrap.sh')
-rw-r--r--pkgs/development/interpreters/python/wrap.sh4
1 files changed, 2 insertions, 2 deletions
diff --git a/pkgs/development/interpreters/python/wrap.sh b/pkgs/development/interpreters/python/wrap.sh
index 030b3d2b6d8..f10ba003432 100644
--- a/pkgs/development/interpreters/python/wrap.sh
+++ b/pkgs/development/interpreters/python/wrap.sh
@@ -84,10 +84,10 @@ wrapPythonProgramsIn() {
                     # We need to support both the case when makeWrapperArgs
                     # is an array and a IFS-separated string.
                     # TODO: remove the string branch when __structuredAttrs are used.
-                    if [[ "$(declare -p makeWrapperArgs)" =~ ^'declare -a makeWrapperArgs=' ]]; then
+                    if [[ "${makeWrapperArgs+defined}" == "defined" && "$(declare -p makeWrapperArgs)" =~ ^'declare -a makeWrapperArgs=' ]]; then
                         local -a user_args=("${makeWrapperArgs[@]}")
                     else
-                        local -a user_args="($makeWrapperArgs)"
+                        local -a user_args="(${makeWrapperArgs:-})"
                     fi
 
                     local -a wrapProgramArgs=("${wrap_args[@]}" "${user_args[@]}")