buildPythonPackage: use a separate file to fire off setup.py

This commit is contained in:
Domen Kožar 2015-11-18 11:44:37 +01:00
parent 960274fc7c
commit f3092d6446
3 changed files with 22 additions and 11 deletions

View File

@ -25,15 +25,19 @@ in stdenv.mkDerivation rec {
unzip -d $out/${python.sitePackages} ${wheel_source} unzip -d $out/${python.sitePackages} ${wheel_source}
''; '';
buildInputs = [ python makeWrapper unzip ]; patchPhase = ''
installPhase = ''
mkdir -p $out/bin mkdir -p $out/bin
# patch pip to support "pip install --prefix" # patch pip to support "pip install --prefix"
# https://github.com/pypa/pip/pull/3252
pushd $out/${python.sitePackages}/ pushd $out/${python.sitePackages}/
patch -p1 < ${./pip-7.0.1-prefix.patch} patch -p1 < ${./pip-7.0.1-prefix.patch}
popd popd
'';
buildInputs = [ python makeWrapper unzip ];
installPhase = ''
# install pip binary # install pip binary
echo '${python.interpreter} -m pip "$@"' > $out/bin/pip echo '${python.interpreter} -m pip "$@"' > $out/bin/pip

View File

@ -50,7 +50,7 @@ then throw "${name} not supported for interpreter ${python.executable}"
else else
let let
setuppy = "import setuptools, tokenize;__file__='setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))"; setuppy = ./run_setup.py;
in in
python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled"] // { python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled"] // {
inherit doCheck; inherit doCheck;
@ -75,18 +75,19 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled"] // {
runHook postConfigure runHook postConfigure
''; '';
checkPhase = attrs.checkPhase or ''
runHook preCheck
${python.interpreter} -c "${setuppy}" test
runHook postCheck
'';
buildPhase = attrs.buildPhase or '' buildPhase = attrs.buildPhase or ''
runHook preBuild runHook preBuild
${python.interpreter} -c "${setuppy}" bdist_wheel cp ${setuppy} nix_run_setup.py
${python.interpreter} nix_run_setup.py build_ext ${lib.concatStringsSep " " setupPyBuildFlags} bdist_wheel
runHook postBuild runHook postBuild
''; '';
checkPhase = attrs.checkPhase or ''
runHook preCheck
${python.interpreter} nix_run_setup.py test
runHook postCheck
'';
installPhase = attrs.installPhase or '' installPhase = attrs.installPhase or ''
runHook preInstall runHook preInstall

View File

@ -0,0 +1,6 @@
import setuptools
import tokenize
__file__='setup.py';
exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))