diff --git a/pkgs/development/interpreters/python/pypy/prebuilt_2_7.nix b/pkgs/development/interpreters/python/pypy/prebuilt_2_7.nix index c987f51295bb..07895c733f84 100644 --- a/pkgs/development/interpreters/python/pypy/prebuilt_2_7.nix +++ b/pkgs/development/interpreters/python/pypy/prebuilt_2_7.nix @@ -1,11 +1,13 @@ { lib , stdenv , fetchurl +, autoPatchelfHook , python-setup-hook , self -, which # Dependencies , bzip2 +, gdbm +, sqlite , zlib , expat , ncurses6 @@ -48,6 +50,8 @@ let deps = [ bzip2 + gdbm + sqlite zlib expat ncurses6 @@ -68,9 +72,13 @@ in with passthru; stdenv.mkDerivation { inherit sha256; }; - buildInputs = [ which ]; + buildInputs = deps; + + nativeBuildInputs = [ autoPatchelfHook ]; installPhase = '' + runHook preInstall + mkdir -p $out/lib echo "Moving files to $out" mv -t $out bin include lib-python lib_pypy site-packages @@ -80,23 +88,20 @@ in with passthru; stdenv.mkDerivation { rm $out/bin/*.debug - echo "Patching binaries" - interpreter=$(patchelf --print-interpreter $(readlink -f $(which patchelf))) - patchelf --set-interpreter $interpreter \ - --set-rpath $out/lib \ - $out/bin/pypy* - - pushd $out - find {lib,lib_pypy*} -name "*.so" -exec patchelf --remove-needed libncursesw.so.6 --replace-needed libtinfow.so.6 libncursesw.so.6 {} \; - find {lib,lib_pypy*} -name "*.so" -exec patchelf --set-rpath ${lib.makeLibraryPath deps}:$out/lib {} \; - echo "Removing bytecode" - find . -name "__pycache__" -type d -depth -exec rm -rf {} \; - popd + find . -name "__pycache__" -type d -depth -delete # Include a sitecustomize.py file cp ${../sitecustomize.py} $out/${sitePackages}/sitecustomize.py + runHook postInstall + ''; + + preFixup = '' + find $out/{lib,lib_pypy*} -name "*.so" \ + -exec patchelf \ + --replace-needed libtinfow.so.6 libncursesw.so.6 \ + --replace-needed libgdbm.so.4 libgdbm_compat.so.4 {} \; ''; doInstallCheck = true;