diff --git a/mingw-w64-python-pillow/001-freeze-support.patch b/mingw-w64-python-pillow/001-freeze-support.patch deleted file mode 100644 index 60639798af..0000000000 --- a/mingw-w64-python-pillow/001-freeze-support.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- Pillow-4.2.1/mp_compile.py.orig 2017-08-18 16:27:09.000000000 +0100 -+++ Pillow-4.2.1/mp_compile.py 2017-08-18 23:34:17.226557000 +0100 -@@ -2,7 +2,7 @@ - import os - import sys - from distutils.ccompiler import CCompiler --from multiprocessing import Pool, cpu_count -+from multiprocessing import Pool, cpu_count, freeze_support - - try: - MAX_PROCS = int(os.environ.get("MAX_CONCURRENCY", min(4, cpu_count()))) -@@ -38,7 +38,9 @@ - output_dir, macros, include_dirs, sources, depends, extra_postargs) - cc_args = self._get_cc_args(pp_opts, debug, extra_preargs) - -- pool = Pool(MAX_PROCS) -+ if __name__ == '__main__': -+ freeze_support() -+ pool = Pool(MAX_PROCS) - try: - print("Building using %d processes" % pool._processes) - except: diff --git a/mingw-w64-python-pillow/001-libtiff-fileio.patch b/mingw-w64-python-pillow/001-libtiff-fileio.patch new file mode 100644 index 0000000000..523dd9a0f2 --- /dev/null +++ b/mingw-w64-python-pillow/001-libtiff-fileio.patch @@ -0,0 +1,66 @@ +From 3cabcf242f472d0aa99ce03f6164787d902091a7 Mon Sep 17 00:00:00 2001 +From: nulano +Date: Sun, 30 Aug 2020 04:30:47 +0200 +Subject: [PATCH] fix libtiff in MSYS2 + +--- + .github/workflows/test-windows.yml | 5 ++--- + setup.py | 4 ++++ + src/libImaging/TiffDecode.c | 15 +++++++++++++-- + 3 files changed, 19 insertions(+), 5 deletions(-) + +diff --git a/setup.py b/setup.py +index ba34fbce78..e1e2eb00df 100755 +--- a/setup.py ++++ b/setup.py +@@ -710,6 +710,10 @@ def build_extensions(self): + if feature.tiff: + libs.append(feature.tiff) + defs.append(("HAVE_LIBTIFF", None)) ++ # FIXME the following define should be detected automatically ++ # based on system libtiff, see #4237 ++ if PLATFORM_MINGW: ++ defs.append(("USE_WIN32_FILEIO", None)) + if feature.xcb: + libs.append(feature.xcb) + defs.append(("HAVE_XCB", None)) +diff --git a/src/libImaging/TiffDecode.c b/src/libImaging/TiffDecode.c +index 532db1f685..f560b14fdb 100644 +--- a/src/libImaging/TiffDecode.c ++++ b/src/libImaging/TiffDecode.c +@@ -20,6 +20,17 @@ + + #include "TiffDecode.h" + ++/* Convert C file descriptor to WinApi HFILE if LibTiff was compiled with tif_win32.c ++ * ++ * This cast is safe, as the top 32-bits of HFILE are guaranteed to be zero, ++ * see https://docs.microsoft.com/en-us/windows/win32/winprog64/interprocess-communication ++ */ ++#ifndef USE_WIN32_FILEIO ++#define fd_to_tiff_fd(fd) (fd) ++#else ++#define fd_to_tiff_fd(fd) ((int)_get_osfhandle(fd)) ++#endif ++ + void dump_state(const TIFFSTATE *state){ + TRACE(("State: Location %u size %d eof %d data: %p ifd: %d\n", (uint)state->loc, + (int)state->size, (uint)state->eof, state->data, state->ifd)); +@@ -316,7 +327,7 @@ int ImagingLibTiffDecode(Imaging im, ImagingCodecState state, UINT8* buffer, Py_ + if (clientstate->fp) { + TRACE(("Opening using fd: %d\n",clientstate->fp)); + lseek(clientstate->fp,0,SEEK_SET); // Sometimes, I get it set to the end. +- tiff = TIFFFdOpen(clientstate->fp, filename, mode); ++ tiff = TIFFFdOpen(fd_to_tiff_fd(clientstate->fp), filename, mode); + } else { + TRACE(("Opening from string\n")); + tiff = TIFFClientOpen(filename, mode, +@@ -521,7 +532,7 @@ int ImagingLibTiffEncodeInit(ImagingCodecState state, char *filename, int fp) { + + if (fp) { + TRACE(("Opening using fd: %d for writing \n",clientstate->fp)); +- clientstate->tiff = TIFFFdOpen(clientstate->fp, filename, mode); ++ clientstate->tiff = TIFFFdOpen(fd_to_tiff_fd(clientstate->fp), filename, mode); + } else { + // malloc a buffer to write the tif, we're going to need to realloc or something if we need bigger. + TRACE(("Opening a buffer for writing \n")); diff --git a/mingw-w64-python-pillow/002-fix-photoimage-crash.patch b/mingw-w64-python-pillow/002-fix-photoimage-crash.patch new file mode 100644 index 0000000000..158ddcec8d --- /dev/null +++ b/mingw-w64-python-pillow/002-fix-photoimage-crash.patch @@ -0,0 +1,22 @@ +From 3273a1af4c4e03559528301a4e4681a453709c26 Mon Sep 17 00:00:00 2001 +From: nulano +Date: Sun, 4 Oct 2020 22:55:53 +0100 +Subject: [PATCH 2/2] fix tk on latest msys2-mingw64 + +--- + src/Tk/tkImaging.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/Tk/tkImaging.c b/src/Tk/tkImaging.c +index 161a835fbd..fdb3a1e1de 100644 +--- a/src/Tk/tkImaging.c ++++ b/src/Tk/tkImaging.c +@@ -63,7 +63,7 @@ ImagingFind(const char* name) + Py_ssize_t id; + + /* FIXME: use CObject instead? */ +-#if defined(_MSC_VER) && defined(_WIN64) ++#if defined(_WIN64) + id = _atoi64(name); + #else + id = atol(name); diff --git a/mingw-w64-python-pillow/002-shared-openjpeg.patch b/mingw-w64-python-pillow/002-shared-openjpeg.patch deleted file mode 100644 index 9ad953b3a4..0000000000 --- a/mingw-w64-python-pillow/002-shared-openjpeg.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- Pillow-5.0.0/setup.py.orig 2018-01-01 10:03:06.000000000 -0500 -+++ Pillow-5.0.0/setup.py 2018-02-17 22:54:51.672853100 -0500 -@@ -597,8 +597,6 @@ class pil_build_ext(build_ext): - if feature.jpeg2000: - libs.append(feature.jpeg2000) - defs.append(("HAVE_OPENJPEG", None)) -- if sys.platform == "win32": -- defs.append(("OPJ_STATIC", None)) - if feature.zlib: - libs.append(feature.zlib) - defs.append(("HAVE_LIBZ", None)) diff --git a/mingw-w64-python-pillow/003-remove-hardcoded-include-path.patch b/mingw-w64-python-pillow/003-remove-hardcoded-include-path.patch new file mode 100644 index 0000000000..d559b8c3c4 --- /dev/null +++ b/mingw-w64-python-pillow/003-remove-hardcoded-include-path.patch @@ -0,0 +1,27 @@ +From 3b38eb317bc9f6ed409accb174d1fb52af8aea8b Mon Sep 17 00:00:00 2001 +From: nulano +Date: Sun, 30 Aug 2020 00:57:27 +0200 +Subject: [PATCH] remove legacy include directory for libimagequant + +1) it is hardcoded to 32-bit C:\msys64\mingw32 +2) current library version uses \mingw64\include\libimagequant.h directly +--- + setup.py | 5 ----- + 1 file changed, 5 deletions(-) + +diff --git a/setup.py b/setup.py +index cf39162502..528a3a0448 100755 +--- a/setup.py ++++ b/setup.py +@@ -528,11 +528,6 @@ def build_extensions(self): + _add_directory(library_dirs, "/lib") + + if sys.platform == "win32": +- if PLATFORM_MINGW: +- _add_directory( +- include_dirs, "C:\\msys64\\mingw32\\include\\libimagequant" +- ) +- + # on Windows, look for the OpenJPEG libraries in the location that + # the official installer puts them + program_files = os.environ.get("ProgramFiles", "") diff --git a/mingw-w64-python-pillow/PKGBUILD b/mingw-w64-python-pillow/PKGBUILD index 250046d79b..d0a4e13e5c 100644 --- a/mingw-w64-python-pillow/PKGBUILD +++ b/mingw-w64-python-pillow/PKGBUILD @@ -3,8 +3,8 @@ _realname=Pillow pkgbase=mingw-w64-python-pillow pkgname=("${MINGW_PACKAGE_PREFIX}-python-pillow") -pkgver=6.2.1 -pkgrel=2 +pkgver=7.2.0 +pkgrel=1 provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}=${pkgver}" "${MINGW_PACKAGE_PREFIX}-python3-pillow=${pkgver}") conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}" @@ -32,40 +32,22 @@ optdepends=("${MINGW_PACKAGE_PREFIX}-tk: for the ImageTK module" "${MINGW_PACKAGE_PREFIX}-libraqm: complex text layout support") options=('staticlibs') source=(${_realname}-${pkgver}.tar.gz::https://github.com/python-pillow/Pillow/archive/${pkgver}.tar.gz - 001-freeze-support.patch - 002-shared-openjpeg.patch - dlopen-fix.patch) -sha256sums=('7bf2d6bdb68fa6ccec15c0fd9aa20fac9641cd20dc6079344f5a6534e13a70f9' - '1abf215cd4730dc57441cb53ecec7ea0ca9870c7251f1d80674ec58ab0f4c7f1' - '581387337db4c6c0a7dae05d6462da92f47e822bd6b482a7a4e7c8637ca7e9f2' - '2154e61a7f88d4f22430fc20097431df827960777320e14f53c8e86e8f4f048b') - -# Helper macros to help make tasks easier # -apply_patch_with_msg() { - for _fname in "$@" - do - msg2 "Applying ${_fname}" - patch -Nbp1 -i "${srcdir}"/${_fname} - done -} - -del_file_exists() { - for _fname in "$@" - do - if [ -f ${_fname} ] || [ -d ${_fname} ]; then - rm -rf ${_fname} - fi - done -} -# =========================================== # + 001-libtiff-fileio.patch + 002-fix-photoimage-crash.patch + 003-remove-hardcoded-include-path.patch) +sha256sums=('0fd19382a1d76d3296f333223ed9429d2110cc0b44ad20b10c5f6255ce9a3bf4' + 'daed469b7ba87ee03830331d79492364966981effe6cf4c71c731a868628adc2' + '1ba2504ab80b0078fbb92b63775ff9e7ef2e637253d6999ace4c023c112c796c' + 'b5067befed4fc347106084f60e5b553c299739dc82fa13915e4480fc1ae19739') prepare() { cd ${srcdir}/${_realname}-${pkgver} - apply_patch_with_msg 001-freeze-support.patch \ - 002-shared-openjpeg.patch \ - dlopen-fix.patch - cd ${srcdir} + patch -Np1 -i "${srcdir}"/001-libtiff-fileio.patch + patch -Np1 -i "${srcdir}"/002-fix-photoimage-crash.patch + patch -Np1 -i "${srcdir}"/003-remove-hardcoded-include-path.patch + + cd ${srcdir} rm -rf python-build-${CARCH} | true cp -r "${_realname}-${pkgver}" "python-build-${CARCH}" } diff --git a/mingw-w64-python-pillow/dlopen-fix.patch b/mingw-w64-python-pillow/dlopen-fix.patch deleted file mode 100644 index 6de64dbc43..0000000000 --- a/mingw-w64-python-pillow/dlopen-fix.patch +++ /dev/null @@ -1,37 +0,0 @@ ---- Pillow-6.1.0.orig/src/_imagingft.c 2019-07-04 23:53:09.565089500 -0400 -+++ Pillow-6.1.0/src/_imagingft.c 2019-07-04 23:59:00.793782000 -0400 -@@ -31,7 +31,7 @@ - #define KEEP_PY_UNICODE - #include "py3.h" - --#if !defined(_MSC_VER) -+#if !defined(_MSC_VER) && !defined(__MINGW32__) - #include - #endif - -@@ -154,20 +154,23 @@ - p_raqm.raqm = NULL; - - /* Microsoft needs a totally different system */ --#if !defined(_MSC_VER) -+#if !defined(_MSC_VER) && !defined(__MINGW32__) - p_raqm.raqm = dlopen("libraqm.so.0", RTLD_LAZY); - if (!p_raqm.raqm) { - p_raqm.raqm = dlopen("libraqm.dylib", RTLD_LAZY); - } - #else - p_raqm.raqm = LoadLibrary("libraqm"); -+ if (!p_raqm.raqm) { -+ p_raqm.raqm = LoadLibrary("libraqm-0.dll"); -+ } - #endif - - if (!p_raqm.raqm) { - return 1; - } - --#if !defined(_MSC_VER) -+#if !defined(_MSC_VER) && !defined(__MINGW32__) - p_raqm.version_atleast = (t_raqm_version_atleast)dlsym(p_raqm.raqm, "raqm_version_atleast"); - p_raqm.create = (t_raqm_create)dlsym(p_raqm.raqm, "raqm_create"); - p_raqm.set_text = (t_raqm_set_text)dlsym(p_raqm.raqm, "raqm_set_text");