pythonInterpreters.pypy27_prebuilt: use autoPatchelfHook

This commit is contained in:
Thiago Kenji Okada 2023-01-06 11:54:36 +00:00
parent a49d01ce3f
commit c89380b0c4

View file

@ -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;