File python-qt4.spec of Package python-qt4

#
# spec file for package python-qt4
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name:           python-qt4
Version:        4.12.1
Release:        0
Summary:        PyQt - python bindings for Qt 4
License:        SUSE-GPL-2.0-with-FLOSS-exception or GPL-3.0 or SUSE-NonFree
Group:          Development/Libraries/Python
Url:            http://www.riverbankcomputing.com/software/pyqt/intro
Source:         http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-%{version}/PyQt4_gpl_x11-%{version}.tar.gz
Source99:       %{name}-rpmlintrc
# PATCH-FIX-UPSTREAM: Fix .pro files not being generated by configure.py
Patch0:         pyqt4_add_pro_files.diff
# PATCH-FIX-UPSTREAM -- TODO
Patch1:         reproducible.patch
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module sip >= 4.19.1}
BuildRequires:  %{python_module sip-devel >= 4.19.1}
BuildRequires:  dbus-1-devel
BuildRequires:  dbus-1-python-devel
BuildRequires:  dbus-1-python3-devel
BuildRequires:  fdupes
BuildRequires:  libqt4-devel
BuildRequires:  phonon-devel
BuildRequires:  python-rpm-macros
Requires:       %{name}-utils
Requires:       python-sip(api) = %python_sip_api_ver
Provides:       python-PyQt4 = %{version}
%requires_ge    python-dbus-python
%requires_ge    libqt4-x11
%ifpython2
%requires_ge    dbus-1-python
%endif
%ifpython3
%requires_ge    dbus-1-python3
%endif

%python_subpackages

%description
PyQt is a set of Python bindings for Trolltech's Qt application
framework and runs on all platforms supported by Qt including Windows,
MacOS/X and Linux. There are two sets of bindings: PyQt v4 supports Qt
v4; and the older PyQt v3 supports Qt v3 and earlier. The bindings are
implemented as a set of Python modules and contain over 300 classes and
nearly 6,000 functions and methods.


%package devel
Summary:        PyQt - devel part of python bindings for Qt 4
Group:          Development/Libraries/Python
Requires:       %{name} = %{version}
Requires:       python-devel
%ifpython2
Requires:       dbus-1-python-devel
%endif
%ifpython3
Requires:       dbus-1-python3-devel
%endif
Requires:       libqt4-devel
Requires:       phonon-devel
Requires:       python-qt4-utils = %{version}
Requires:       python-sip-devel >= 4.19.1
Recommends:     python-qscintilla
Provides:       python-PyQt4-devel = %{version}
Requires(post): update-alternatives
Requires(preun): update-alternatives

%description devel
PyQt is a set of Python bindings for Trolltech's Qt application
framework and runs on all platforms supported by Qt including Windows,
MacOS/X and Linux. There are two sets of bindings: PyQt v4 supports Qt
v4; and the older PyQt v3 supports Qt v3 and earlier. The bindings are
implemented as a set of Python modules and contain over 300 classes and
nearly 6,000 functions and methods.

This package contains all the developer tools you need to create your
own PyQt applications.


%package -n %{name}-utils
Summary:        Common files for PyQt4 for python2 and python3
Group:          Development/Libraries/Python
Provides:       %{python_module PyQt4-utils = %{version}}
Provides:       %{python_module qt4-utils = %{version}}

%description -n %{name}-utils
PyQt is a set of Python bindings for Trolltech's Qt application
framework and runs on all platforms supported by Qt including Windows,
MacOS/X and Linux. There are two sets of bindings: PyQt v4 supports Qt
v4; and the older PyQt v3 supports Qt v3 and earlier. The bindings are
implemented as a set of Python modules and contain over 300 classes and
nearly 6,000 functions and methods.

This package contains common files shared between python2 and python3
versions of PyQt4.


%package -n %{name}-doc
Summary:        Documentation for %{name}
Group:          Documentation/Other
Provides:       %{python_module PyQt4-doc = %{version}}
Provides:       %{python_module qt4-doc = %{version}}

%description -n %{name}-doc
PyQt is a set of Python bindings for Trolltech's Qt application
framework and runs on all platforms supported by Qt including Windows,
MacOS/X and Linux. There are two sets of bindings: PyQt v4 supports Qt
v4; and the older PyQt v3 supports Qt v3 and earlier. The bindings are
implemented as a set of Python modules and contain over 300 classes and
nearly 6,000 functions and methods.

This package contains documentation and examples for PyQt4.


%prep
%setup -q -n PyQt4_gpl_x11-%{version}
%patch0 -p1
%patch1 -p1
# Fix wrong-script-interpreter
find examples -name "*.py" -exec sed -i "s|^#!/usr/bin/env python$|#!%__python3|" {} \;

%build
export CXXFLAGS="%{optflags}"
export CFLAGS="%{optflags}"

%{python_expand mkdir build_%{$python_bin_suffix}
pushd build_%{$python_bin_suffix}

$python ../configure-ng.py --verbose \
                           --confirm-license \
                           --qsci-api \
                           --debug \
                           --sip=%{_bindir}/sip-%{$python_bin_suffix}

make %{?_smp_mflags}

popd

}

%install
mkdir -p %{buildroot}%{_sysconfdir}/alternatives

%{python_expand pushd build_%{$python_bin_suffix}

%make_install INSTALL_ROOT=%{buildroot}

# Point to the correct location for the documentation files
cp ../README ./
sed -i 's/The "doc" directory/The "doc" directory of package %{$python_prefix}-qt4-devel/' README

popd

mv %{buildroot}%{_libdir}/qt4/plugins/designer/libpyqt4.so %{buildroot}%{_libdir}/qt4/plugins/designer/libpy%{$python_bin_suffix}qt4.so
mv -T %{buildroot}%{_datadir}/qt4/qsci/api/python %{buildroot}%{_datadir}/qt4/qsci/api/python_%{$python_bin_suffix}

%fdupes %{buildroot}%{python_sitearch}
}

mkdir -p %{buildroot}%{_docdir}/%{name}
cp -r doc %{buildroot}%{_docdir}/%{name}/
cp -r examples %{buildroot}%{_docdir}/%{name}/
%fdupes %{buildroot}%{_docdir}/%{name}/

%python_clone -a %{buildroot}%{_bindir}/pyuic4
%python_clone -a %{buildroot}%{_bindir}/pylupdate4
%python_clone -a %{buildroot}%{_bindir}/pyrcc4

%post devel
%{python_install_alternative pyuic4 pylupdate4 pyrcc4}

%preun devel
%python_uninstall_alternative pyuic4

%files %{python_files}
%defattr(-,root,root)
%doc build_%{python_bin_suffix}/README
%doc ChangeLog LICENSE NEWS THANKS 
%{python_sitearch}/PyQt4/
%{python_sitelib}/dbus/mainloop/qt.so
%exclude %{_docdir}/%{name}/doc/
%exclude %{_docdir}/%{name}/examples/

%files %{python_files devel}
%defattr(-,root,root)
%doc LICENSE
%python_alternative %{_bindir}/pyuic4
%python_alternative %{_bindir}/pylupdate4
%python_alternative %{_bindir}/pyrcc4
%{_libdir}/qt4/plugins/designer/libpy%{python_bin_suffix}qt4.so
%dir %{_datadir}/qt4/qsci/
%dir %{_datadir}/qt4/qsci/api/
%dir %{_datadir}/qt4/qsci/api/python_%{python_bin_suffix}/
%{_datadir}/qt4/qsci/api/python_%{python_bin_suffix}/PyQt4.api

%files -n %{name}-utils
%defattr(-,root,root)
%doc LICENSE
%{_datadir}/sip/PyQt4/

%files -n %{name}-doc
%defattr(-,root,root)
%doc LICENSE
%dir %{_docdir}/%{name}
%{_docdir}/%{name}/doc/
%{_docdir}/%{name}/examples/

%changelog
openSUSE Build Service is sponsored by