about summary refs log tree commit diff
path: root/pkgs/development/python-modules
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2011-03-28 16:33:33 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2011-03-28 16:33:33 +0000
commit47adaa80e310ed270b2bccb05cf2c10d30cde453 (patch)
tree27ff8c9be064967b0b264814fb7fee57137b87b0 /pkgs/development/python-modules
parent641834ddf6aa2e3876378f04ee4f47c3b2153542 (diff)
downloadnixlib-47adaa80e310ed270b2bccb05cf2c10d30cde453.tar
nixlib-47adaa80e310ed270b2bccb05cf2c10d30cde453.tar.gz
nixlib-47adaa80e310ed270b2bccb05cf2c10d30cde453.tar.bz2
nixlib-47adaa80e310ed270b2bccb05cf2c10d30cde453.tar.lz
nixlib-47adaa80e310ed270b2bccb05cf2c10d30cde453.tar.xz
nixlib-47adaa80e310ed270b2bccb05cf2c10d30cde453.tar.zst
nixlib-47adaa80e310ed270b2bccb05cf2c10d30cde453.zip
* Move the wrapPythonPrograms function into a separate setup hook
  (wrapPython).

svn path=/nixpkgs/branches/modular-python/; revision=26580
Diffstat (limited to 'pkgs/development/python-modules')
-rw-r--r--pkgs/development/python-modules/generic/default.nix45
-rw-r--r--pkgs/development/python-modules/generic/wrap.sh40
2 files changed, 43 insertions, 42 deletions
diff --git a/pkgs/development/python-modules/generic/default.nix b/pkgs/development/python-modules/generic/default.nix
index 1152a0aa447b..146de620d57c 100644
--- a/pkgs/development/python-modules/generic/default.nix
+++ b/pkgs/development/python-modules/generic/default.nix
@@ -3,7 +3,7 @@
    (http://pypi.python.org/pypi/setuptools/), which represents a large
    number of Python packages nowadays.  */
 
-{ python, setuptools, makeWrapper, lib }:
+{ python, setuptools, wrapPython, lib }:
 
 { name, namePrefix ? "python-"
 
@@ -36,7 +36,7 @@ python.stdenv.mkDerivation (attrs // {
 
   name = namePrefix + name;
 
-  buildInputs = [ python makeWrapper setuptools ] ++ buildInputs ++ pythonPath;
+  buildInputs = [ python wrapPython setuptools ] ++ buildInputs ++ pythonPath;
 
   pythonPath = [ setuptools] ++ pythonPath;
 
@@ -54,47 +54,8 @@ python.stdenv.mkDerivation (attrs // {
 
   postFixup =
     ''
-      declare -A pythonPathsSeen
+      wrapPythonPrograms
     
-      addToPythonPath() {
-          local dir="$1"
-          if [ -n "''${pythonPathsSeen[$dir]}" ]; then return; fi
-          pythonPathsSeen[$dir]=1
-          addToSearchPath program_PYTHONPATH $dir/lib/${python.libPrefix}/site-packages
-          addToSearchPath program_PATH $dir/bin
-          local prop="$dir/nix-support/propagated-build-native-inputs"
-          if [ -e $prop ]; then
-              local i
-              for i in $(cat $prop); do
-                  addToPythonPath $i
-              done
-          fi
-      }
-    
-      wrapPythonPrograms() {
-          local dir="$1"
-          local pythonPath="$2"
-          local i
-
-          pythonPathsSeen=()
-          program_PYTHONPATH=
-          program_PATH=
-          for i in $pythonPath; do
-              addToPythonPath $i
-          done
-
-          for i in $(find "$out" -type f -perm +0100); do
-              if head -n1 "$i" | grep -q "${python}"; then
-                  echo "wrapping \`$i'..."
-                  wrapProgram "$i" \
-                    --prefix PYTHONPATH ":" $program_PYTHONPATH \
-                    --prefix PATH ":" $program_PATH
-              fi
-          done
-      }
-
-      wrapPythonPrograms $out "$out $pythonPath"
-
       # If a user installs a Python package, she probably also wants its
       # dependencies in the user environment (since Python modules don't
       # have something like an RPATH, so the only way to find the
diff --git a/pkgs/development/python-modules/generic/wrap.sh b/pkgs/development/python-modules/generic/wrap.sh
new file mode 100644
index 000000000000..98162c8807f7
--- /dev/null
+++ b/pkgs/development/python-modules/generic/wrap.sh
@@ -0,0 +1,40 @@
+wrapPythonPrograms() {
+    wrapPythonProgramsIn $out "$out $pythonPath"
+}
+
+wrapPythonProgramsIn() {
+    local dir="$1"
+    local pythonPath="$2"
+    local i
+
+    declare -A pythonPathsSeen=()
+    program_PYTHONPATH=
+    program_PATH=
+    for i in $pythonPath; do
+        _addToPythonPath $i
+    done
+
+    for i in $(find "$dir" -type f -perm +0100); do
+        if head -n1 "$i" | grep -q /python; then
+            echo "wrapping \`$i'..."
+            wrapProgram "$i" \
+                --prefix PYTHONPATH ":" $program_PYTHONPATH \
+                --prefix PATH ":" $program_PATH
+        fi
+    done
+}
+
+_addToPythonPath() {
+    local dir="$1"
+    if [ -n "${pythonPathsSeen[$dir]}" ]; then return; fi
+    pythonPathsSeen[$dir]=1
+    addToSearchPath program_PYTHONPATH $dir/lib/python2.7/site-packages
+    addToSearchPath program_PATH $dir/bin
+    local prop="$dir/nix-support/propagated-build-native-inputs"
+    if [ -e $prop ]; then
+        local i
+        for i in $(cat $prop); do
+            _addToPythonPath $i
+        done
+    fi
+}