From e7c1aa52cc9594fa48622c2048ab69766f3f27d3 Mon Sep 17 00:00:00 2001 From: Florian Friesdorf Date: Sat, 21 Jul 2012 00:11:02 +0200 Subject: [PATCH 1/4] python: rename eventually created easy_install.pth to pkg-specific file --- pkgs/development/python-modules/generic/default.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/development/python-modules/generic/default.nix b/pkgs/development/python-modules/generic/default.nix index 4e0b61002316..4aa17d28b258 100644 --- a/pkgs/development/python-modules/generic/default.nix +++ b/pkgs/development/python-modules/generic/default.nix @@ -20,6 +20,15 @@ , installCommand ? '' easy_install --prefix="$out" . + + # A pth file might have been generated to load the package from + # within its own site-packages, rename this package not to + # collide with others. + eapth="$out/lib/${python.libPrefix}"/site-packages/easy-install.pth + if [ -e "$eapth" ]; then + # move colliding easy_install.pth to specifically named one + mv "$eapth" $(dirname "$eapth")/${name}.pth + fi '' , buildPhase ? "true" From 2c3ffeb79c9baabd36bcd24a054121c06f204026 Mon Sep 17 00:00:00 2001 From: Florian Friesdorf Date: Sat, 21 Jul 2012 00:11:17 +0200 Subject: [PATCH 2/4] python: remove colliding site.py* files --- pkgs/development/python-modules/generic/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/development/python-modules/generic/default.nix b/pkgs/development/python-modules/generic/default.nix index 4aa17d28b258..3a6024e09a8b 100644 --- a/pkgs/development/python-modules/generic/default.nix +++ b/pkgs/development/python-modules/generic/default.nix @@ -29,6 +29,11 @@ # move colliding easy_install.pth to specifically named one mv "$eapth" $(dirname "$eapth")/${name}.pth fi + + # Remove any site.py files generated by easy_install as these + # cause collisions. If pth files are to be processed a + # corresponding site.py needs to be included in the PYTHONPATH. + rm -f "$out/lib/${python.libPrefix}"/site-packages/site.py* '' , buildPhase ? "true" From a40da09b444ad00c46d952bc4b4ac9e5cd51c6f9 Mon Sep 17 00:00:00 2001 From: Florian Friesdorf Date: Sat, 21 Jul 2012 01:55:50 +0200 Subject: [PATCH 3/4] python: create pth files for python build inputs (propagate/native or not) --- pkgs/development/python-modules/generic/default.nix | 11 ++++++++++- pkgs/development/python-modules/generic/wrap.sh | 12 ++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/generic/default.nix b/pkgs/development/python-modules/generic/default.nix index 3a6024e09a8b..6e8794103bc2 100644 --- a/pkgs/development/python-modules/generic/default.nix +++ b/pkgs/development/python-modules/generic/default.nix @@ -59,6 +59,8 @@ python.stdenv.mkDerivation (attrs // { buildInputs = [ python wrapPython setuptools ] ++ buildInputs ++ pythonPath; + buildInputStrings = map toString buildInputs; + pythonPath = [ setuptools] ++ pythonPath; # XXX: Should we run `easy_install --always-unzip'? It doesn't seem @@ -76,7 +78,7 @@ python.stdenv.mkDerivation (attrs // { postFixup = '' wrapPythonPrograms - + # 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 @@ -84,5 +86,12 @@ python.stdenv.mkDerivation (attrs // { if test -e $out/nix-support/propagated-build-inputs; then ln -s $out/nix-support/propagated-build-inputs $out/nix-support/propagated-user-env-packages fi + + createBuildInputsPth build-inputs "$buildInputStrings" + for inputsfile in propagated-build-inputs propagated-build-native-inputs; do + if test -e $out/nix-support/$inputsfile; then + createBuildInputsPth $inputsfile "$(cat $out/nix-support/$inputsfile)" + fi + done ''; }) diff --git a/pkgs/development/python-modules/generic/wrap.sh b/pkgs/development/python-modules/generic/wrap.sh index 65f3229ca7c4..7cc728491900 100644 --- a/pkgs/development/python-modules/generic/wrap.sh +++ b/pkgs/development/python-modules/generic/wrap.sh @@ -45,3 +45,15 @@ _addToPythonPath() { done fi } + +createBuildInputsPth() { + local category="$1" + local inputs="$2" + if [ foo"$inputs" != foo ]; then + for x in $inputs; do + if test -d "$x"/lib/@libPrefix@/site-packages; then + echo $x >> "$out"/lib/@libPrefix@/site-packages/${name}-nix-python-$category.pth + fi + done + fi +} From f8d3671629441fd6b528a532e9d3356d8d21f168 Mon Sep 17 00:00:00 2001 From: Florian Friesdorf Date: Sun, 22 Jul 2012 02:07:23 +0200 Subject: [PATCH 4/4] fix pth files --- pkgs/development/python-modules/generic/wrap.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/generic/wrap.sh b/pkgs/development/python-modules/generic/wrap.sh index 7cc728491900..71269945d6f4 100644 --- a/pkgs/development/python-modules/generic/wrap.sh +++ b/pkgs/development/python-modules/generic/wrap.sh @@ -52,7 +52,8 @@ createBuildInputsPth() { if [ foo"$inputs" != foo ]; then for x in $inputs; do if test -d "$x"/lib/@libPrefix@/site-packages; then - echo $x >> "$out"/lib/@libPrefix@/site-packages/${name}-nix-python-$category.pth + echo $x/lib/@libPrefix@/site-packages \ + >> "$out"/lib/@libPrefix@/site-packages/${name}-nix-python-$category.pth fi done fi