From 293a0000d828d4f8cbd312aa7942866ba38c85f2 Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 5 Oct 2023 13:22:02 +0200 Subject: [PATCH] Add PIL and setuptools for mod bootstrap Signed-off-by: falkTX --- bootstrap-mod.sh | 57 +++++++++++++++++++++++++++++++ patches/Pillow/01_fix-build.patch | 25 ++++++++++++++ setup/functions.sh | 6 ++-- 3 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 patches/Pillow/01_fix-build.patch diff --git a/bootstrap-mod.sh b/bootstrap-mod.sh index ecf7f32..764bbf2 100755 --- a/bootstrap-mod.sh +++ b/bootstrap-mod.sh @@ -140,6 +140,63 @@ if [ "${WIN32}" -eq 1 ] && [ "${CROSS_COMPILING}" -eq 1 ]; then unset PYTHONPATH fi +# --------------------------------------------------------------------------------------------------------------------- +# Pillow + +PILLOW_VERSION="8.2.0" + +if [ "${WIN32}" -eq 1 ]; then + export EXTRA_CFLAGS="$(${PAWPAW_PREFIX}/bin/pkg-config --cflags python3 freetype2 libpng)" + export EXTRA_LDFLAGS="-shared $(${PAWPAW_PREFIX}/bin/pkg-config --libs python3 freetype2 libpng) -lgdi32 -lkernel32 -lpsapi -luser32" + export LDSHARED="${TARGET_CXX}" +fi + +PILLOW_EXTRAFLAGS="" +PILLOW_EXTRAFLAGS+=" --enable-freetype" +PILLOW_EXTRAFLAGS+=" --enable-zlib" +PILLOW_EXTRAFLAGS+=" --disable-imagequant" +PILLOW_EXTRAFLAGS+=" --disable-jpeg" +PILLOW_EXTRAFLAGS+=" --disable-jpeg2000" +PILLOW_EXTRAFLAGS+=" --disable-tiff" +PILLOW_EXTRAFLAGS+=" --disable-webp" +PILLOW_EXTRAFLAGS+=" --disable-webpmux" +PILLOW_EXTRAFLAGS+=" --disable-xcb" +PILLOW_EXTRAFLAGS+=" --disable-platform-guessing" + +download Pillow "${PILLOW_VERSION}" "https://files.pythonhosted.org/packages/21/23/af6bac2a601be6670064a817273d4190b79df6f74d8012926a39bc7aa77f" +build_python Pillow "${PILLOW_VERSION}" "${PILLOW_EXTRAFLAGS}" + +if [ "${WIN32}" -eq 1 ]; then + unset LDSHARED +fi + +if [ "${WIN32}" -eq 1 ] && [ "${CROSS_COMPILING}" -eq 1 ]; then + PYTHONPATH="${PAWPAW_PREFIX}/lib/python3.8/site-packages" + if [ ! -e "${PYTHONPATH}/PIL" ]; then + ln -sv "${PYTHONPATH}"/Pillow-*.egg/PIL "${PYTHONPATH}/PIL" + fi + unset PYTHONPATH +fi + +# --------------------------------------------------------------------------------------------------------------------- +# setuptools + +SETUPTOOLS_VERSION="68.2.2" + +download setuptools "${SETUPTOOLS_VERSION}" "https://files.pythonhosted.org/packages/ef/cc/93f7213b2ab5ed383f98ce8020e632ef256b406b8569606c3f160ed8e1c9" +build_python setuptools "${SETUPTOOLS_VERSION}" + +if [ "${WIN32}" -eq 1 ] && [ "${CROSS_COMPILING}" -eq 1 ]; then + PYTHONPATH="${PAWPAW_PREFIX}/lib/python3.8/site-packages" + if [ ! -e "${PYTHONPATH}/pkg_resources" ]; then + ln -sv "${PYTHONPATH}"/setuptools-*.egg/pkg_resources "${PYTHONPATH}/pkg_resources" + fi + if [ ! -e "${PYTHONPATH}/setuptools" ]; then + ln -sv "${PYTHONPATH}"/setuptools-*.egg/setuptools "${PYTHONPATH}/setuptools" + fi + unset PYTHONPATH +fi + # --------------------------------------------------------------------------------------------------------------------- # tornado diff --git a/patches/Pillow/01_fix-build.patch b/patches/Pillow/01_fix-build.patch new file mode 100644 index 0000000..4599101 --- /dev/null +++ b/patches/Pillow/01_fix-build.patch @@ -0,0 +1,25 @@ +diff --git a/setup.py b/setup.py +index 52babbc..60426d4 100755 +--- a/setup.py ++++ b/setup.py +@@ -1017,7 +1017,6 @@ try: + packages=["PIL"], + package_dir={"": "src"}, + keywords=["Imaging"], +- zip_safe=not (debug_build() or PLATFORM_MINGW), + ) + except RequiredDependencyException as err: + msg = f""" +diff --git a/src/libImaging/ImPlatform.h b/src/libImaging/ImPlatform.h +index 9a2060e..c956fc0 100644 +--- a/src/libImaging/ImPlatform.h ++++ b/src/libImaging/ImPlatform.h +@@ -34,7 +34,7 @@ + #ifdef _WIN32 + + #define WIN32_LEAN_AND_MEAN +-#include ++#include + + #else + /* For System that are not Windows, we'll need to define these. */ diff --git a/setup/functions.sh b/setup/functions.sh index 5fabd50..43d6626 100644 --- a/setup/functions.sh +++ b/setup/functions.sh @@ -479,7 +479,7 @@ function build_python() { if [ ! -f "${pkgdir}/.stamp_built" ]; then pushd "${pkgdir}" - ${python} setup.py build ${extraconfrules} --verbose + ${python} setup.py build_ext ${extraconfrules} --verbose -j1 touch .stamp_built popd fi @@ -487,8 +487,8 @@ function build_python() { if [ ! -f "${pkgdir}/.stamp_installed" ]; then pushd "${pkgdir}" # always try twice, python checks for installed deps and fails the first time - ${python} setup.py install --prefix="${PAWPAW_PREFIX}" ${extraconfrules} --verbose || \ - ${python} setup.py install --prefix="${PAWPAW_PREFIX}" ${extraconfrules} --verbose + ${python} setup.py install --prefix="${PAWPAW_PREFIX}" --verbose || \ + ${python} setup.py install --prefix="${PAWPAW_PREFIX}" --verbose touch .stamp_installed popd fi