From c89380b0c4ca9db893995669e012a63b587f9263 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Fri, 6 Jan 2023 11:54:36 +0000 Subject: [PATCH] pythonInterpreters.pypy27_prebuilt: use autoPatchelfHook --- .../interpreters/python/pypy/prebuilt_2_7.nix | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) 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;