Author: chaoflow
Date: Sun Feb 26 17:23:38 2012
New Revision: 32592
URL: https://nixos.org/websvn/nix/?rev=32592&sc=1

Log:
include site in pythonpath of wrapped scripts, if python-site is installed

Added:
   nixpkgs/branches/stdenv-updates/pkgs/development/python-modules/site/pysite
Modified:
   
nixpkgs/branches/stdenv-updates/pkgs/development/python-modules/generic/wrap.sh
   
nixpkgs/branches/stdenv-updates/pkgs/development/python-modules/site/default.nix

Modified: 
nixpkgs/branches/stdenv-updates/pkgs/development/python-modules/generic/wrap.sh
==============================================================================
--- 
nixpkgs/branches/stdenv-updates/pkgs/development/python-modules/generic/wrap.sh 
    Sun Feb 26 17:23:35 2012        (r32591)
+++ 
nixpkgs/branches/stdenv-updates/pkgs/development/python-modules/generic/wrap.sh 
    Sun Feb 26 17:23:38 2012        (r32592)
@@ -15,6 +15,14 @@
         _addToPythonPath $i
     done
 
+    program_PYTHONPATH='$(
+        # activate site if installed
+        bindir=$(dirname "$0")
+        pysite="$bindir/pysite"
+        relpath=$(test -x "$pysite" && "$pysite" path)
+        echo -n ${relpath:+"$relpath":}
+)'"$program_PYTHONPATH"
+
     for i in $(find "$dir" -type f -perm +0100); do
 
         # Rewrite "#! .../env python" to "#! /nix/store/.../python".
@@ -25,7 +33,7 @@
         if head -n1 "$i" | grep -q /python; then
             echo "wrapping \`$i'..."
             wrapProgram "$i" \
-                --prefix PYTHONPATH ":" $program_PYTHONPATH \
+                --prefix PYTHONPATH ":" "$program_PYTHONPATH" \
                 --prefix PATH ":" $program_PATH
         fi
     done

Modified: 
nixpkgs/branches/stdenv-updates/pkgs/development/python-modules/site/default.nix
==============================================================================
--- 
nixpkgs/branches/stdenv-updates/pkgs/development/python-modules/site/default.nix
    Sun Feb 26 17:23:35 2012        (r32591)
+++ 
nixpkgs/branches/stdenv-updates/pkgs/development/python-modules/site/default.nix
    Sun Feb 26 17:23:38 2012        (r32592)
@@ -12,6 +12,16 @@
       dst=$out/lib/${python.libPrefix}/site-packages
       mkdir -p $dst
       cat ${./site.py} >> $dst/site.py
+
+      # by providing content for bin/ we make sure, that python or
+      # some other script is linked instead of the bin/ directory
+      # itself. This is needed for the wrappers to make all site
+      # packages available if site is installed.
+      mkdir $out/bin
+      cat ${./pysite} >> $out/bin/pysite
+      substituteInPlace $out/bin/pysite \
+          --replace PYTHON_LIB_PREFIX ${python.libPrefix}
+      chmod +x $out/bin/pysite
     '';
 
   meta = {

Added: 
nixpkgs/branches/stdenv-updates/pkgs/development/python-modules/site/pysite
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ nixpkgs/branches/stdenv-updates/pkgs/development/python-modules/site/pysite 
Sun Feb 26 17:23:38 2012        (r32592)
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+python=PYTHON_LIB_PREFIX
+
+case "$1" in
+    path)
+        echo $(dirname $0)/../lib/$python/site-packages
+        ;;
+    *)
+        echo Usage:
+        echo "  $(basename $0) path"
+        exit 1
+esac
_______________________________________________
nix-commits mailing list
nix-comm...@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-commits

Reply via email to