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

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

@ -50,7 +50,7 @@ then throw "${name} not supported for interpreter ${python.executable}"
else
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
python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled"] // {
inherit doCheck;
@ -75,18 +75,19 @@ python.stdenv.mkDerivation (builtins.removeAttrs attrs ["disabled"] // {
runHook postConfigure
'';
checkPhase = attrs.checkPhase or ''
runHook preCheck
${python.interpreter} -c "${setuppy}" test
runHook postCheck
'';
buildPhase = attrs.buildPhase or ''
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
'';
checkPhase = attrs.checkPhase or ''
runHook preCheck
${python.interpreter} nix_run_setup.py test
runHook postCheck
'';
installPhase = attrs.installPhase or ''
runHook preInstall

@ -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'))