File python3-pyside2.spec of Package python3-pyside2

#
# spec file for package python3-pyside2
#
# 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 https://bugs.opensuse.org/
#


%bcond_with tests

%define mypython python3
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
Name:           python3-pyside2

Version:        5.9
Release:        0
Summary:        PySide - python bindings for Qt
License:        LGPL-3.0-only OR (GPL-2.0-only OR GPL-3.0-or-later)
Group:          Development/Languages/Python
URL:            http://wiki.qt.io/Qt_for_Python
Source0:        pyside-setup-%{version}.tar.xz
Patch1:         fix-cmake.patch
Patch2:         lib64.patch
# PATCH-FIX-OPENSUSE - PYSIDE-882
#Patch3:         0001-Avoid-creation-of-empty-build-directories-in-install.patch
# PATCH-FIX-OPENSUSE - PYSIDE-881
Patch4:         0001-Remove-unnecessary-she-bang-from-icon-cache.py.patch
BuildRequires:  cmake
BuildRequires:  fdupes
BuildRequires:  gcc-c++

BuildRequires:  libqt5-qtdeclarative-private-headers-devel

##### essential modules
BuildRequires:  pkgconfig(Qt5Concurrent)
BuildConflicts: pkgconfig(Qt5Core) >= 5.10
BuildRequires:  pkgconfig(Qt5Core) >= 5.9
BuildRequires:  pkgconfig(Qt5Network)
BuildRequires:  pkgconfig(Qt5PrintSupport)
BuildRequires:  pkgconfig(Qt5Sql)
BuildRequires:  pkgconfig(Qt5Test)
BuildRequires:  pkgconfig(Qt5Widgets)
BuildRequires:  pkgconfig(Qt5X11Extras)
BuildRequires:  pkgconfig(Qt5Xml)
BuildRequires:  pkgconfig(Qt5XmlPatterns)

##### optional modules
BuildRequires:  libQt53DQuickScene2D5
BuildRequires:  pkgconfig(Qt53DAnimation)
BuildRequires:  pkgconfig(Qt53DCore)
BuildRequires:  pkgconfig(Qt53DExtras)
BuildRequires:  pkgconfig(Qt53DInput)
BuildRequires:  pkgconfig(Qt53DLogic)
BuildRequires:  pkgconfig(Qt53DRender)
BuildRequires:  pkgconfig(Qt5Charts)
BuildRequires:  pkgconfig(Qt5DataVisualization)
BuildRequires:  pkgconfig(Qt5Designer)
BuildRequires:  pkgconfig(Qt5Multimedia)
BuildRequires:  pkgconfig(Qt5MultimediaWidgets)
BuildRequires:  pkgconfig(Qt5OpenGL)
BuildRequires:  pkgconfig(Qt5QuickWidgets)
BuildRequires:  pkgconfig(Qt5Script)
BuildRequires:  pkgconfig(Qt5ScriptTools)
BuildRequires:  pkgconfig(Qt5Scxml)
BuildRequires:  pkgconfig(Qt5Svg)
BuildRequires:  pkgconfig(Qt5TextToSpeech)
BuildRequires:  pkgconfig(Qt5WebChannel)
BuildRequires:  pkgconfig(Qt5WebEngineWidgets)
BuildRequires:  pkgconfig(Qt5WebSockets)
BuildRequires:  pkgconfig(Qt5Widgets)
BuildRequires:  pkgconfig(Qt5Xml)
BuildRequires:  pkgconfig(Qt5XmlPatterns)
#BuildRequires:  pkgconfig(Qt5Vector3D)
# WebKit modules is to be removed when FreeCAD 0.18 is released
BuildRequires:  pkgconfig(Qt5WebKit)

BuildRequires:  clang-devel >= 3.9
BuildRequires:  libxslt-devel
BuildRequires:  python3-Sphinx
BuildRequires:  python3-idna
BuildRequires:  python3-urllib3

%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.

%package examples
Summary:        Examples for using PySide2
Group:          Development/Languages/Python
Requires:       %{name} = %{version}

%description examples
Examples and Tutorials for the PySide2 bindings for Qt.

%prep
%setup -q -n pyside-setup-%{version}
%patch1 -p1
%if "%{_lib}" == "lib64"
%patch2 -p1
%endif
#%%patch3 -p1
%patch4 -p1 -d sources/pyside2-tools/

%build
export LLVM_INSTALL_DIR=%{_prefix}
export CFLAGS=-I/usr/include/linux
# Workaround for PYSIDE-880
export LC_ALL=C.utf8
export CC=clang
export CXX=clang++
%{mypython} setup.py build --reuse-build --ignore-git --parallel=%{?jobs:%jobs}%{!?jobs:1} \
%if %{with tests}
  --build-tests
%endif

%install
export LC_ALL=C.utf8
export CC=clang
export CXX=clang++
%{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}/

#cp -a ./pyside3_build/py*-release/pyside2/PySide2/*.pyi %{buildroot}%{py_sitedir}/PySide2/

cp -a ./examples %{buildroot}%{_datadir}/PySide2/

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

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

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

sed -i 's,env python,python,' %{buildroot}/%{_bindir}/pyside2-uic

rm %{buildroot}%{_bindir}/*_tool.py
rm -Rf %{buildroot}%{py_sitedir}/pyside2uic/port_v2/
rm -Rf %{buildroot}%{_datadir}/PySide2/typesystems/typesystem_*_win.xml

%fdupes -s %{buildroot}%{_datadir}/PySide2/examples/

# docu generation
cd docs
make html
cd -

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

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

%files
%license LICENSE.*
%{_bindir}/*
%{_libdir}/*.so.*
%{py_sitedir}/*

%files devel
%doc docs/_build/html
%{_datadir}/PySide2/
%exclude %{_datadir}/PySide2/examples
%{_includedir}/*
%{_libdir}/*.so
%{_libdir}/cmake
%{_libdir}/pkgconfig
%{_mandir}/man*/*

%files examples
%dir %{_datadir}/PySide2
%{_datadir}/PySide2/examples

%changelog