From f3092d6446986b9e72f356648d077dbdc98f6bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Wed, 18 Nov 2015 11:44:37 +0100 Subject: [PATCH] buildPythonPackage: use a separate file to fire off setup.py --- .../python-modules/bootstrapped-pip/default.nix | 10 +++++++--- .../python-modules/generic/default.nix | 17 +++++++++-------- .../python-modules/generic/run_setup.py | 6 ++++++ 3 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 pkgs/development/python-modules/generic/run_setup.py diff --git a/pkgs/development/python-modules/bootstrapped-pip/default.nix b/pkgs/development/python-modules/bootstrapped-pip/default.nix index 5578b3a83c4d..677736270290 100644 --- a/pkgs/development/python-modules/bootstrapped-pip/default.nix +++ b/pkgs/development/python-modules/bootstrapped-pip/default.nix @@ -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 diff --git a/pkgs/development/python-modules/generic/default.nix b/pkgs/development/python-modules/generic/default.nix index 75115526a41e..0a2fd429f002 100644 --- a/pkgs/development/python-modules/generic/default.nix +++ b/pkgs/development/python-modules/generic/default.nix @@ -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 diff --git a/pkgs/development/python-modules/generic/run_setup.py b/pkgs/development/python-modules/generic/run_setup.py new file mode 100644 index 000000000000..d980ac7d23d4 --- /dev/null +++ b/pkgs/development/python-modules/generic/run_setup.py @@ -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'))