From 75aac284e6b16ff003da30fdc8b95b78c19114d4 Mon Sep 17 00:00:00 2001 From: Jeremy Rand Date: Fri, 6 May 2022 11:32:20 +0000 Subject: [PATCH] python-windows: Add libffi dependency --- projects/python-windows/build | 18 ++++++++++++++++-- projects/python-windows/config | 7 +++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/projects/python-windows/build b/projects/python-windows/build index c501eaf..6aaea85 100644 --- a/projects/python-windows/build +++ b/projects/python-windows/build @@ -10,6 +10,20 @@ openssldir=/var/tmp/dist/openssl/openssl cp -a $openssldir/include/openssl /var/tmp/dist/mingw-w64/[% c("arch") %]-w64-mingw32/include/openssl cp -a $openssldir/lib/* $openssldir/bin/*.dll /var/tmp/dist/mingw-w64/[% c("arch") %]-w64-mingw32/lib/ +# Required for "import ctypes" +tar -C /var/tmp/dist -xf [% c('input_files_by_name/libffi-src') %] +pushd /var/tmp/dist/*libffi* +# The Python devs got high on LSD and appear to have committed the libffi +# source code from a Windows machine, which stripped off all the +x bits. +# Kids, drugs and coding don't mix. +chmod -R +x ./ +./configure --host=[% c("arch") %]-w64-mingw32 +# Always errors on this step, but still produces the .dll files we want. +make || true +cp ./[% c("arch") %]-w64-mingw32/include/*.h /var/tmp/dist/mingw-w64/[% c("arch") %]-w64-mingw32/include +cp ./[% c("arch") %]-w64-mingw32/.libs/* /var/tmp/dist/mingw-w64/[% c("arch") %]-w64-mingw32/lib/ +popd + mkdir -p /var/tmp/build tar -C /var/tmp/build -xf [% c('input_files_by_name/python') %] tar -C /var/tmp/build -xf [% c('input_files_by_name/meson') %] @@ -65,8 +79,8 @@ ninja -C builddir install find $distdir -name '*.a' -exec rm '{}' + # These files don't reproduce, and are useless -# Required for "import ssl" -cp $openssldir/bin/*.dll $gcclibs/*.dll $distdir/bin/ +# Required for "import ssl" and "import ctypes" +cp $openssldir/bin/*.dll /var/tmp/dist/*libffi*/[% c("arch") %]-w64-mingw32/.libs/*.dll $gcclibs/*.dll $distdir/bin/ cd /var/tmp/dist [% c('tar', { diff --git a/projects/python-windows/config b/projects/python-windows/config index a0132d5..6dde4fa 100644 --- a/projects/python-windows/config +++ b/projects/python-windows/config @@ -14,6 +14,10 @@ var: - zip - git # maybe possible to omit these compiler: mingw-w64 + post_pkginst: | + mkdir -p /usr/i686-w64-mingw32/sys-root/mingw/lib/libffi-3.1/ + # Yes, Meson uses "i686" in the sysroot name even for 64-bit. v0v + ln -s -T /var/tmp/dist/cpython-source-deps-libffi-3.4.2/[% c("arch") %]-w64-mingw32/include /usr/i686-w64-mingw32/sys-root/mingw/lib/libffi-3.1/include input_files: - project: container-image @@ -53,4 +57,7 @@ input_files: - filename: omit-build-timestamp.patch - name: openssl project: openssl + - name: libffi-src + URL: https://github.com/python/cpython-source-deps/archive/refs/tags/libffi-3.4.2.tar.gz + sha256sum: 9f9edfbb59a142a8624cec574eeac0caf98c2e51a15e6c9f099b83aaf0942c22