Add mingw subpackages

This commit is contained in:
Sandro Mani 2022-02-24 15:47:21 +01:00
parent 17852b5c42
commit bd534fbae3
4 changed files with 183 additions and 5 deletions

78
pillow_mingw.patch Normal file
View File

@ -0,0 +1,78 @@
diff -rupN --no-dereference Pillow-9.0.1/setup.py Pillow-9.0.1-new/setup.py
--- Pillow-9.0.1/setup.py 2022-02-03 00:45:27.000000000 +0100
+++ Pillow-9.0.1-new/setup.py 2022-02-23 09:06:33.272472288 +0100
@@ -135,7 +135,7 @@ class RequiredDependencyException(Except
pass
-PLATFORM_MINGW = os.name == "nt" and "GCC" in sys.version
+PLATFORM_MINGW = "mingw32" in os.getenv("CC")
PLATFORM_PYPY = hasattr(sys, "pypy_version_info")
@@ -497,7 +497,7 @@ class pil_build_ext(build_ext):
#
# add platform directories
- if self.disable_platform_guessing:
+ if self.disable_platform_guessing or PLATFORM_MINGW:
pass
elif sys.platform == "cygwin":
@@ -589,7 +589,7 @@ class pil_build_ext(build_ext):
# FIXME: check /opt/stuff directories here?
# standard locations
- if not self.disable_platform_guessing:
+ if not self.disable_platform_guessing and not PLATFORM_MINGW:
_add_directory(library_dirs, "/usr/local/lib")
_add_directory(include_dirs, "/usr/local/include")
@@ -835,7 +835,7 @@ class pil_build_ext(build_ext):
if feature.xcb:
libs.append(feature.xcb)
defs.append(("HAVE_XCB", None))
- if sys.platform == "win32":
+ if sys.platform == "win32" or PLATFORM_MINGW:
libs.extend(["kernel32", "user32", "gdi32"])
if struct.unpack("h", b"\0\1")[0] == 1:
defs.append(("WORDS_BIGENDIAN", None))
@@ -857,6 +857,8 @@ class pil_build_ext(build_ext):
if feature.freetype:
srcs = []
libs = ["freetype"]
+ if sys.platform == "win32" or PLATFORM_MINGW:
+ libs.extend(["dl"])
defs = []
if feature.raqm:
if not feature.want_vendor("raqm"): # using system Raqm
@@ -879,7 +881,7 @@ class pil_build_ext(build_ext):
if feature.lcms:
extra = []
- if sys.platform == "win32":
+ if sys.platform == "win32" or PLATFORM_MINGW:
extra.extend(["user32", "gdi32"])
self._update_extension("PIL._imagingcms", [feature.lcms] + extra)
else:
@@ -898,7 +900,7 @@ class pil_build_ext(build_ext):
else:
self._remove_extension("PIL._webp")
- tk_libs = ["psapi"] if sys.platform in ("win32", "cygwin") else []
+ tk_libs = ["psapi"] if sys.platform in ("win32", "cygwin") or PLATFORM_MINGW else []
self._update_extension("PIL._imagingtk", tk_libs)
build_ext.build_extensions(self)
diff -rupN --no-dereference Pillow-9.0.1/src/libImaging/ImPlatform.h Pillow-9.0.1-new/src/libImaging/ImPlatform.h
--- Pillow-9.0.1/src/libImaging/ImPlatform.h 2022-02-03 00:45:27.000000000 +0100
+++ Pillow-9.0.1-new/src/libImaging/ImPlatform.h 2022-02-23 09:06:33.272472288 +0100
@@ -28,7 +28,7 @@
#if defined(_WIN32) || defined(__CYGWIN__)
#define WIN32_LEAN_AND_MEAN
-#include <Windows.h>
+#include <windows.h>
#ifdef __CYGWIN__
#undef _WIN64

View File

@ -5,13 +5,15 @@
# EPEL9 is missing some dependencies to build the documentation
%if 0%{?el9}
%bcond_with doc
%bcond_with mingw
%else
%bcond_without doc
%bcond_without mingw
%endif
Name: python-%{srcname}
Version: 9.0.1
Release: 1%{?dist}
Release: 4%{?dist}
Summary: Python image processing library
# License: see http://www.pythonware.com/products/pil/license.htm
@ -23,6 +25,8 @@ Source0: https://github.com/python-pillow/Pillow/archive/%{version}/Pillo
Patch0: python-pillow_spinxwarn.patch
# Drop sphinx plugin requirements which are not packaged for Fedora
Patch1: python-pillow_sphinx.patch
# MinGW build fixes
Patch2: pillow_mingw.patch
BuildRequires: freetype-devel
BuildRequires: gcc
@ -53,6 +57,38 @@ BuildRequires: python%{python3_pkgversion}-sphinx-removed-in
%endif
BuildRequires: python%{python3_pkgversion}-tkinter
%if %{with mingw}
BuildRequires: mingw32-filesystem >= 95
BuildRequires: mingw32-gcc
BuildRequires: mingw32-python3
BuildRequires: mingw32-python3-setuptools
BuildRequires: mingw32-dlfcn
BuildRequires: mingw32-freetype
BuildRequires: mingw32-lcms2
BuildRequires: mingw32-libimagequant
BuildRequires: mingw32-libjpeg
BuildRequires: mingw32-libtiff
BuildRequires: mingw32-libwebp
BuildRequires: mingw32-openjpeg2
BuildRequires: mingw32-tk
BuildRequires: mingw32-zlib
BuildRequires: mingw64-filesystem >= 95
BuildRequires: mingw64-gcc
BuildRequires: mingw64-python3
BuildRequires: mingw64-python3-setuptools
BuildRequires: mingw64-dlfcn
BuildRequires: mingw64-freetype
BuildRequires: mingw64-lcms2
BuildRequires: mingw64-libimagequant
BuildRequires: mingw64-libjpeg
BuildRequires: mingw64-libtiff
BuildRequires: mingw64-libwebp
BuildRequires: mingw64-openjpeg2
BuildRequires: mingw64-tk
BuildRequires: mingw64-zlib
%endif
# For EpsImagePlugin.py
Requires: ghostscript
@ -129,14 +165,40 @@ Provides: python%{python3_pkgversion}-imaging-qt = %{version}-%{release}
Qt %{srcname} image wrapper.
%if %{with mingw}
%package -n mingw32-python3-%{name}
Summary: MinGW Windows Python2 %{name} library
%description -n mingw32-python3-%{name}
MinGW Windows Python2 %{name} library.
%package -n mingw64-python3-%{name}
Summary: MinGW Windows Python2 %{name} library
%description -n mingw64-python3-%{name}
MinGW Windows Python2 %{name} library.
%{?mingw_debug_package}
%endif
%prep
%autosetup -p1 -n Pillow-%{version}
%build
# Build Python 3 modules
# Native build
%py3_build
# MinGW build
%if %{with mingw}
PKG_CONFIG=mingw32-pkg-config %{mingw32_py3_build}
PKG_CONFIG=mingw64-pkg-config %{mingw64_py3_build}
%endif
# Doc build
%if %{with doc}
PYTHONPATH=$PWD/build/%py3_libbuilddir make -C docs html BUILDDIR=_build_py3 SPHINXBUILD=sphinx-build-%python3_version
rm -f docs/_build_py3/html/.buildinfo
@ -144,11 +206,32 @@ rm -f docs/_build_py3/html/.buildinfo
%install
# Install Python 3 modules
# Native build
install -d %{buildroot}/%{py3_incdir}/Imaging
install -m 644 src/libImaging/*.h %{buildroot}/%{py3_incdir}/Imaging
%py3_install
# MinGW build
%if %{with mingw}
install -d %{buildroot}/%{mingw32_py3_incdir}/Imaging
install -m 644 src/libImaging/*.h %{buildroot}/%{mingw32_py3_incdir}/Imaging
install -d %{buildroot}/%{mingw64_py3_incdir}/Imaging
install -m 644 src/libImaging/*.h %{buildroot}/%{mingw64_py3_incdir}/Imaging
%{mingw32_py3_install}
%{mingw64_py3_install}
# Remove sample scripts
rm -rf %{buildroot}%{mingw32_bindir}
rm -rf %{buildroot}%{mingw64_bindir}
%endif
%if %{with mingw}
%mingw_debug_install_post
%endif
%check
# Check Python 3 modules
@ -198,8 +281,25 @@ popd
%{python3_sitearch}/PIL/ImageQt*
%{python3_sitearch}/PIL/__pycache__/ImageQt*
%if %{with mingw}
%files -n mingw32-python3-%{name}
%license docs/COPYING
%{mingw32_python3_sitearch}/PIL/
%{mingw32_python3_sitearch}/Pillow-%{version}-py%{mingw32_python3_version}.egg-info/
%{mingw32_py3_incdir}/Imaging/
%files -n mingw64-python3-%{name}
%license docs/COPYING
%{mingw64_python3_sitearch}/PIL/
%{mingw64_python3_sitearch}/Pillow-%{version}-py%{mingw64_python3_version}.egg-info/
%{mingw64_py3_incdir}/Imaging/
%endif
%changelog
* Thu Feb 24 2022 Sandro Mani <manisandro@gmail.com> - 9.0.1-4
- Add mingw subpackages
* Thu Feb 03 2022 Sandro Mani <manisandro@gmail.com> - 9.0.1-1
- Update to 9.0.1

View File

@ -1,6 +1,6 @@
diff -rupN --no-dereference Pillow-9.0.1/docs/conf.py Pillow-9.0.1-new/docs/conf.py
--- Pillow-9.0.1/docs/conf.py 2022-02-03 00:45:27.000000000 +0100
+++ Pillow-9.0.1-new/docs/conf.py 2022-02-03 08:56:43.525506916 +0100
+++ Pillow-9.0.1-new/docs/conf.py 2022-02-23 09:06:33.169472252 +0100
@@ -30,12 +30,10 @@ needs_sphinx = "2.4"
# ones.
extensions = [

View File

@ -1,6 +1,6 @@
diff -rupN --no-dereference Pillow-9.0.1/docs/Makefile Pillow-9.0.1-new/docs/Makefile
--- Pillow-9.0.1/docs/Makefile 2022-02-03 00:45:27.000000000 +0100
+++ Pillow-9.0.1-new/docs/Makefile 2022-02-03 08:56:43.436506725 +0100
+++ Pillow-9.0.1-new/docs/Makefile 2022-02-23 09:06:33.060472214 +0100
@@ -42,7 +42,7 @@ clean:
-rm -rf $(BUILDDIR)/*