* Move the wrapPythonPrograms function into a separate setup hook
(wrapPython). svn path=/nixpkgs/branches/modular-python/; revision=26580
This commit is contained in:
parent
641834ddf6
commit
47adaa80e3
@ -1,4 +1,4 @@
|
||||
{ stdenv, fetchurl, python, pythonPackages, makeWrapper }:
|
||||
{ stdenv, fetchurl, python, pythonPackages, wrapPython }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
version = "2.3";
|
||||
@ -10,11 +10,13 @@ stdenv.mkDerivation rec {
|
||||
sha256 = "07kx41w4gqv68bcykdflsg68wvpmcyqknzyb4vr1zqlf27hahp53";
|
||||
};
|
||||
|
||||
buildInputs = [ python makeWrapper ];
|
||||
buildInputs = [ python wrapPython ];
|
||||
|
||||
pythonPath = [ pythonPackages.ssl ];
|
||||
|
||||
installPhase = ''
|
||||
python setup.py install --prefix=$out
|
||||
wrapProgram $out/bin/bzr --prefix PYTHONPATH : "$(toPythonPath $out ${pythonPackages.ssl})"
|
||||
wrapPythonPrograms
|
||||
'';
|
||||
|
||||
meta = {
|
||||
|
@ -45,12 +45,14 @@ rec {
|
||||
|
||||
|
||||
# Make a package that just contains a setup hook with the given contents.
|
||||
makeSetupHook = script:
|
||||
runCommand "hook" {}
|
||||
''
|
||||
makeSetupHook = deps: script:
|
||||
runCommand "hook" { }
|
||||
(''
|
||||
ensureDir $out/nix-support
|
||||
cp ${script} $out/nix-support/setup-hook
|
||||
'';
|
||||
'' + stdenv.lib.optionalString (deps != []) ''
|
||||
echo ${toString deps} > $out/nix-support/propagated-build-native-inputs
|
||||
'');
|
||||
|
||||
|
||||
# Write the references (i.e. the runtime dependencies in the Nix store) of `path' to a file.
|
||||
|
@ -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
|
||||
|
40
pkgs/development/python-modules/generic/wrap.sh
Normal file
40
pkgs/development/python-modules/generic/wrap.sh
Normal file
@ -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
|
||||
}
|
@ -312,7 +312,9 @@ let
|
||||
inherit stdenv perl cpio contents ubootChooser;
|
||||
};
|
||||
|
||||
makeWrapper = makeSetupHook ../build-support/make-wrapper/make-wrapper.sh;
|
||||
makeWrapper = makeSetupHook [] ../build-support/make-wrapper/make-wrapper.sh;
|
||||
|
||||
wrapPython = makeSetupHook [ makeWrapper ] ../development/python-modules/generic/wrap.sh;
|
||||
|
||||
makeModulesClosure = {kernel, rootModules, allowMissing ? false}:
|
||||
import ../build-support/kernel/modules-closure.nix {
|
||||
@ -343,6 +345,7 @@ let
|
||||
};
|
||||
|
||||
platforms = import ./platforms.nix;
|
||||
|
||||
|
||||
### TOOLS
|
||||
|
||||
@ -4264,7 +4267,7 @@ let
|
||||
buildPythonPackage = buildPython27Package;
|
||||
|
||||
buildPython27Package = import ../development/python-modules/generic {
|
||||
inherit makeWrapper lib;
|
||||
inherit wrapPython lib;
|
||||
python = python27;
|
||||
setuptools = setuptools.override { python = python27; doCheck = false; };
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user