Blob Blame History Raw
%{?mingw_package_header}

# Disable debuginfo subpackages and debugsource packages for now to use old logic
%undefine _debugsource_packages
%undefine _debuginfo_subpackages

# Override the __debug_install_post argument as this package
# contains both native as well as cross compiled binaries
%global __debug_install_post %%{mingw_debug_install_post}; %{_rpmconfigdir}/find-debuginfo.sh %{?_missing_build_ids_terminate_build:--strict-build-id} %{?_find_debuginfo_opts} "%{_builddir}/%%{?buildsubdir}" %{nil}


%global native_dir %{_builddir}/native-%{name}-%{version}-%{release}
%global win64_dir %{_builddir}/mingw64-%{name}-%{version}-%{release}

%global pkgname python-qt5
%global qt_ver 5.9.1

Name:           mingw-%{pkgname}
Summary:        MinGW Windows PyQt5
Version:        5.9
Release:        4%{?dist}

# GPLv2 exceptions(see GPL_EXCEPTIONS*.txt)
License:        (GPLv3 or GPLv2 with exceptions) and BSD
Url:            http://www.riverbankcomputing.com/software/pyqt/
Source0:        http://downloads.sourceforge.net/project/pyqt/PyQt5/PyQt-%{version}/PyQt5_gpl-%{version}.zip
# Tweak configure for cross build
Patch0:         PyQt5_configure.patch
# Hack in WS_WIN instead of WS_X11 in sip-flags
Patch1:         PyQt5_wswin.patch

BuildRequires:  python2-devel
BuildRequires:  sip-devel
BuildRequires:  qt5-qtbase-devel >= %{qt_ver}
BuildRequires:  qt5-qtsvg-devel >= %{qt_ver}
BuildRequires:  qt5-qttools-devel >= %{qt_ver}
BuildRequires:  qt5-qtwebkit-devel >= %{qt_ver}
BuildRequires:  qt5-qtxmlpatterns-devel >= %{qt_ver}

BuildRequires:  mingw32-filesystem >= 102
BuildRequires:  mingw32-gcc-c++
BuildRequires:  mingw32-python2
BuildRequires:  mingw32-qt5-qtbase >= %{qt_ver}
BuildRequires:  mingw32-qt5-qtsvg >= %{qt_ver}
BuildRequires:  mingw32-qt5-qttools >= %{qt_ver}
BuildRequires:  mingw32-qt5-qtwebkit >= %{qt_ver}
BuildRequires:  mingw32-qt5-qtxmlpatterns >= %{qt_ver}
BuildRequires:  mingw32-sip

BuildRequires:  mingw64-filesystem >= 102
BuildRequires:  mingw64-gcc-c++
BuildRequires:  mingw64-python2
BuildRequires:  mingw64-qt5-qtbase >= %{qt_ver}
BuildRequires:  mingw64-qt5-qtsvg >= %{qt_ver}
BuildRequires:  mingw64-qt5-qttools >= %{qt_ver}
BuildRequires:  mingw64-qt5-qtwebkit >= %{qt_ver}
BuildRequires:  mingw64-qt5-qtxmlpatterns >= %{qt_ver}
BuildRequires:  mingw64-sip

%description
MinGW Windows PyQt5

%package -n mingw32-python2-qt5
Summary:       MinGW Windows Python2-Qt5
Requires:      qt5-qtbase = %{qt_ver}
Requires:      sip
Requires:      mingw32-qt5-qtbase >= %{qt_ver}
Requires:      mingw32-qt5-qttools >= %{qt_ver}
Requires:      mingw32-sip

%description -n mingw32-python2-qt5
MinGW Windows Python2-Qt5


%package -n mingw64-python2-qt5
Summary:       MinGW Windows Python2-Qt5
Requires:      qt5-qtbase = %{qt_ver}
Requires:      sip
Requires:      mingw64-qt5-qtbase >= %{qt_ver}
Requires:      mingw64-qt5-qttools >= %{qt_ver}
Requires:      mingw64-sip

%description -n mingw64-python2-qt5
MinGW Windows Python2-Qt5


%{?mingw_debug_package}


%prep
%setup -q -n PyQt5_gpl-%{version}

rm -rf %{native_dir}
cp -a . %{native_dir}
pushd %{native_dir}
%patch1 -p1
popd

%patch0 -p1
rm -rf %{win64_dir}
cp -a . %{win64_dir}

%build
PREFIX=%{mingw32_prefix} mingw32-python configure.py \
  --assume-shared \
  --confirm-license \
  --sip=/usr/bin/mingw32-sip \
  --qmake=%{mingw32_qmake_qt5} \
  --no-qsci-api \
  --verbose

%mingw32_make %{?_smp_mflags}

(
cd %{win64_dir}
PREFIX=%{mingw64_prefix} mingw64-python configure.py \
  --assume-shared \
  --confirm-license \
  --sip=/usr/bin/mingw64-sip \
  --qmake=%{mingw64_qmake_qt5} \
  --no-qsci-api \
  --verbose

%mingw64_make %{?_smp_mflags}
)

(
cd %{native_dir}
%{__python2} configure.py \
  --assume-shared \
  --confirm-license \
  --qmake=%{_qt5_qmake} \
  --no-qsci-api \
  --verbose

%make_build
)


%install
%mingw32_make install INSTALL_ROOT=%{buildroot}
%mingw32_make install INSTALL_ROOT=%{buildroot} -C %{win64_dir}
%mingw32_make install INSTALL_ROOT=%{buildroot} -C %{native_dir}

# Remove Python 3 code from Python 2.x directory
rm -rf %{buildroot}%{mingw32_python2_sitearch}/PyQt5/uic/port_v3/
rm -rf %{buildroot}%{mingw64_python2_sitearch}/PyQt5/uic/port_v3/
rm -rf %{buildroot}%{python2_sitearch}/PyQt5/uic/port_v3/

# Move native build to host libs
find %{buildroot}%{python2_sitearch}/PyQt5/ -type f -name '*.so' -exec chmod +x {} \;
mkdir -p %{buildroot}%{_prefix}/%{mingw32_target}/lib/python2.7/site-packages/
mkdir -p %{buildroot}%{_prefix}/%{mingw64_target}/lib/python2.7/site-packages/
cp -a %{buildroot}%{python2_sitearch}/PyQt5 %{buildroot}%{_prefix}/%{mingw32_target}/lib/python2.7/site-packages/PyQt5
cp -a %{buildroot}%{python2_sitearch}/PyQt5 %{buildroot}%{_prefix}/%{mingw64_target}/lib/python2.7/site-packages/PyQt5

# Remove pylupdate, pyuic and pyrcc shell scripts
rm -f %{buildroot}%{mingw32_bindir}/py{lupdate,rcc,uic}5
rm -f %{buildroot}%{mingw64_bindir}/py{lupdate,rcc,uic}5

# Remove unused stuff
rm -rf %{buildroot}%{_libdir}
rm -rf %{buildroot}%{_bindir}
rm -rf %{buildroot}%{_datadir}

# Exclude debug files from the main files (note: the debug files are only created after %%install, so we can't search for them directly)
find %{buildroot}%{mingw32_prefix} | grep -E '.(exe|dll|pyd)$' | sed 's|^%{buildroot}\(.*\)$|%%exclude \1.debug|' > mingw32-%{pkgname}.debugfiles
find %{buildroot}%{mingw64_prefix} | grep -E '.(exe|dll|pyd)$' | sed 's|^%{buildroot}\(.*\)$|%%exclude \1.debug|' > mingw64-%{pkgname}.debugfiles


%files -n mingw32-python2-qt5 -f mingw32-%{pkgname}.debugfiles
%license LICENSE
%{_prefix}/%{mingw32_target}/lib/python2.7/site-packages/PyQt5/
%{mingw32_python2_sitearch}/PyQt5/
%{mingw32_libdir}/qt5/plugins/designer/pyqt5.dll
%{mingw32_libdir}/qt5/plugins/PyQt5/
%{mingw32_datadir}/sip/PyQt5


%files -n mingw64-python2-qt5 -f mingw64-%{pkgname}.debugfiles
%license LICENSE
%{_prefix}/%{mingw64_target}/lib/python2.7/site-packages/PyQt5/
%{mingw64_python2_sitearch}/PyQt5/
%{mingw64_libdir}/qt5/plugins/designer/pyqt5.dll
%{mingw64_libdir}/qt5/plugins/PyQt5/
%{mingw64_datadir}/sip/PyQt5


%changelog
* Tue Sep 19 2017 Sandro Mani <manisandro@gmail.com> - 5.9-4
- Rebuild (mingw-filesystem)

* Tue Sep 05 2017 Sandro Mani <manisandro@gmail.com> - 5.9-3
- Require mingw{32,64}-qt5-qttools for directory ownership

* Wed Aug 09 2017 Sandro Mani <manisandro@gmail.com> - 5.9-2
- Bump qt_ver to 5.9.1

* Tue Jul 11 2017 Sandro Mani <manisandro@gmail.com> - 5.9-1
- Update to 5.9

* Sat May 06 2017 Sandro Mani <manisandro@gmail.com> - 5.8.2-1
- Initial package