File python-pyside2.spec of Package python-pyside2

#
# spec file for package python
#
# Copyright (c) 2018 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/
#


%bcond_with tests

%if "@BUILD_FLAVOR@" == ""
ExclusiveArch:  do_not_build
Name:           do_not_build
%endif
%if "@BUILD_FLAVOR@" == "python3-pyside2"
%define mypython python3
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
Name:           python3-pyside2
%else
%define mypython python
BuildRequires:  python-devel >= 2.6
BuildRequires:  python-setuptools
Name:           python-pyside2
%endif

%define supported_min_qt 5.9

Version:        2.0~pre.1519723362.e621f811
Release:        0
Summary:        PySide - python bindings for Qt
License:        LGPL-2.1-or-later
Group:          Development/Languages/Python
Url:            http://qt-project.org/wiki/PySide
Source0:        pyside-setup-%{version}.tar.xz
# PATCH-FIX-UPSTREAM broken cmake files
Patch1:         fix-cmake.patch
# PATCH-FIX-UPSTREAM missing lib suffix handling
Patch2:         lib64.patch
# PATCH-FIX-OPENSUSE Do not add 5.10 API if compile with 5.9 https://bugreports.qt.io/browse/PYSIDE-573
Patch3:         0001-Remove-5.10-API-in-Qt-5.9.patch
BuildRequires:  cmake
BuildRequires:  fdupes
BuildRequires:  gcc-c++

BuildRequires:  git
BuildRequires:  libqt5-qtdeclarative-private-headers-devel

##### essential modules
BuildRequires:  pkgconfig(Qt5Concurrent) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5Core) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5Network) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5PrintSupport) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5Sql) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5Test) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5Widgets) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5X11Extras) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5Xml) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5XmlPatterns) >= %{supported_min_qt}

##### optional modules
BuildRequires:  pkgconfig(Qt53DAnimation) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt53DCore) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt53DExtras) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt53DInput) >= %{supported_min_qt} 
BuildRequires:  pkgconfig(Qt53DLogic) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt53DQuickScene2D) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt53DRender) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5Charts) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5DataVisualization) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5Designer) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5Multimedia) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5MultimediaWidgets) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5OpenGL) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5QuickWidgets) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5Script) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5ScriptTools) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5Svg) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5TextToSpeech) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5WebChannel) >= %{supported_min_qt}
%ifnarch ppc ppc64 ppc64le s390 s390x
BuildRequires:  pkgconfig(Qt5WebEngineWidgets)
%endif
BuildRequires:  pkgconfig(Qt5WebSockets) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5Widgets) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5Xml) >= %{supported_min_qt}
BuildRequires:  pkgconfig(Qt5XmlPatterns) >= %{supported_min_qt}

BuildRequires:  libxslt-devel
BuildRequires:  llvm-clang-devel >= 3.9
BuildRequires:  llvm-devel >= 3.9
BuildRequires:  python-devel >= 2.6
BuildRequires:  python-setuptools

%description
The PySide2 project provides Python bindings for the Qt
application and UI framework.

%package devel
Summary:        Header Files for PySide2
Group:          Development/Languages/Python
Requires:       %name = %{version}

%description devel
Files needed for development with the PySide2 bindings
for Qt.

%prep
%setup -q -n pyside-setup-%{version}
%patch1 -p1
%if "%{_libdir}" == "/usr/lib64"
%patch2 -p1
%endif
%if 0%{?suse_version} < 1550
%patch3 -p1
%endif

%build
export CFLAGS=-I/usr/include/linux
%mypython setup.py build --reuse-build --ignore-git \
%if %{with tests}
  --build-tests
%endif

%install
%mypython setup.py install --reuse-build --ignore-git --prefix=%{_prefix} --root=%{buildroot} \
%if %{with tests}
  --build-tests
%endif

# and hack re-installation, since setup is doing it wrong
rm -rf %{buildroot}/*
mkdir -p %{buildroot}/%{_libdir}
cp -a ./pyside?_install/py*-release/* %{buildroot}%{_prefix}/

sed -i 's,=.*/pyside._install/[^\/]*,=/usr,' %{buildroot}%{_prefix}/lib/pkgconfig/*.pc
sed -i 's,^libdir=.*,libdir=%{_libdir},' %{buildroot}%{_prefix}/lib/pkgconfig/*.pc

sed -i 's,"[^"]*/include/shiboken2","/usr/include/shiboken2",' %{buildroot}%{_prefix}/lib/cmake/Shiboken*/*.cmake
sed -i 's,"[^"]*/lib/libshiboken2.\(.*\)","%{_libdir}/libshiboken2.\1",' %{buildroot}%{_prefix}/lib/cmake/Shiboken*/*.cmake
sed -i 's,"[^"]*/bin/shiboken2","%{_prefix}/bin/shiboken2",' %{buildroot}%{_prefix}/lib/cmake/Shiboken*/*.cmake
sed -i 's,^include("[^"]*-release/lib/,include("%{_libdir}/,' %{buildroot}%{_prefix}/lib/cmake/Shiboken*/*.cmake

sed -i 's,"[^"]*/include/PySide2","/usr/include/PySide2",' %{buildroot}%{_prefix}/lib/cmake/PySide2*/*.cmake
sed -i 's,"[^"]*/lib/cmake/\(.*\)","%{_libdir}/cmake/\1",' %{buildroot}%{_prefix}/lib/cmake/PySide2*/*.cmake
sed -i 's,"[^"]*/lib/libpyside2\.\(.*\)","%{_libdir}/libpyside2.\1",' %{buildroot}%{_prefix}/lib/cmake/PySide2*/*.cmake
sed -i 's,"[^"]*/\(python.*/site-packages\)","%{_libdir}/\1",' %{buildroot}%{_prefix}/lib/cmake/PySide2*/*.cmake
sed -i 's,"[^"]*/share/PySide2/typesystems","%{_prefix}/share/PySide2/typesystems",' %{buildroot}%{_prefix}/lib/cmake/PySide2*/*.cmake
sed -i 's,^include("[^"]*-release/lib/,include("%{_libdir}/,' %{buildroot}%{_prefix}/lib/cmake/PySide2*/*.cmake

%if "%{_libdir}" == "/usr/lib64"
mv %{buildroot}%{_prefix}/lib/lib* %{buildroot}/%{_libdir}/
mv %{buildroot}%{_prefix}/lib/pkgconfig %{buildroot}/%{_libdir}/
mv %{buildroot}%{_prefix}/lib/cmake %{buildroot}/%{_libdir}/
rmdir %{buildroot}%{_prefix}/lib
%endif

%check
%if %{with tests}
%mypython testrunner.py test
%endif

%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%files
%defattr(-,root,root)
%doc LICENSE.*
%{_prefix}/bin/*
%{_libdir}/*.so.*
%if "@BUILD_FLAVOR@" == "python3-pyside2"
%{python3_sitearch}/*
%else
%{py_sitedir}/*
%endif

%files devel
%defattr(-,root,root)
%{_mandir}/man*/*
%{_prefix}/include/*
%{_libdir}/*.so
%{_libdir}/cmake
%{_libdir}/pkgconfig
%{_datadir}/PySide2

%changelog
openSUSE Build Service is sponsored by