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 { lib
, stdenv , stdenv
, fetchurl , fetchurl
, autoPatchelfHook
, python-setup-hook , python-setup-hook
, self , self
, which
# Dependencies # Dependencies
, bzip2 , bzip2
, gdbm
, sqlite
, zlib , zlib
, expat , expat
, ncurses6 , ncurses6
@ -48,6 +50,8 @@ let
deps = [ deps = [
bzip2 bzip2
gdbm
sqlite
zlib zlib
expat expat
ncurses6 ncurses6
@ -68,9 +72,13 @@ in with passthru; stdenv.mkDerivation {
inherit sha256; inherit sha256;
}; };
buildInputs = [ which ]; buildInputs = deps;
nativeBuildInputs = [ autoPatchelfHook ];
installPhase = '' installPhase = ''
runHook preInstall
mkdir -p $out/lib mkdir -p $out/lib
echo "Moving files to $out" echo "Moving files to $out"
mv -t $out bin include lib-python lib_pypy site-packages mv -t $out bin include lib-python lib_pypy site-packages
@ -80,23 +88,20 @@ in with passthru; stdenv.mkDerivation {
rm $out/bin/*.debug 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" echo "Removing bytecode"
find . -name "__pycache__" -type d -depth -exec rm -rf {} \; find . -name "__pycache__" -type d -depth -delete
popd
# Include a sitecustomize.py file # Include a sitecustomize.py file
cp ${../sitecustomize.py} $out/${sitePackages}/sitecustomize.py 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; doInstallCheck = true;