File python-gobject.spec of Package python-gobject

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


# This figures in an error message
%global __requires_exclude typelib\\(%%namespaces\\)
%define build_for_python3 0

%if %{build_for_python3}
%define local_py_requires Requires: python(abi) = %py3_ver
%define local_py_sitedir  %{python3_sitearch}
%define local_py_suffix   3
%define local_py_pkg      python3
%define local_lib_ver     3-0
%else
%define local_py_requires %{py_requires}
%define local_py_sitedir  %{py_sitedir}
%define local_py_suffix   2
%define local_py_pkg      python 
%define local_lib_ver     2-0
%endif

Name:           python-gobject
%define _name   pygobject
Summary:        Python bindings for GObject
License:        LGPL-2.1+
Group:          Development/Libraries/Python
Version:        3.20.1
Release:        0
Url:            https://wiki.gnome.org/Projects/PyGObject/
Source:         http://download.gnome.org/sources/pygobject/3.20/%{_name}-%{version}.tar.xz
# PATCH-FIX-UPSTREAM pycompile-searchpath.patch jmatejek@suse.com -- Fix build with python 3.4
Patch1:         pycompile-searchpath.patch
BuildRequires:  fdupes
BuildRequires:  glib2-devel >= 2.38.0
BuildRequires:  gobject-introspection-devel >= 1.46.0
BuildRequires:  libffi-devel >= 3.0.0
%if %{build_for_python3}
BuildRequires:  python3-cairo-devel
BuildRequires:  python3-devel
%else
BuildRequires:  python-cairo-devel
BuildRequires:  python-devel
%endif
BuildRequires:  pkgconfig(cairo)
BuildRequires:  pkgconfig(cairo-gobject)
# Trigger an automatic installation of python(3)?-gobject when python and libgirepository are installed.
Supplements:    packageand(%{local_py_pkg}:libgirepository-1_0-1)
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%{local_py_requires}

%description
Pygobjects is an extension module for python that gives you access to
GLib's GObjects.

%package Gdk
Summary:        Python bindings for GObject -- Gdk bindings
Group:          Development/Libraries/Python
Requires:       %{name} = %{version}
Requires:       %{name}-cairo = %{version}
%define gdk_real_package %(rpm -q --qf '%%{NAME}' -f $(readlink /usr/lib64/libgdk-3.so -f))
Supplements:    packageand(%{name}:%{gdk_real_package})

%description Gdk
Pygobjects is an extension module for python that gives you access to
GLib's GObjects.

This package contains the Python Gdk bindings for GObject.

%package cairo
Summary:        Python bindings for GObject -- Cairo bindings
Group:          Development/Libraries/Python
Requires:       %{name} = %{version}
%define cairo_real_package %(rpm -q --qf '%%{NAME}' --whatprovides cairo)
Supplements:    packageand(%{name}:%{cairo_real_package})

%description cairo
Pygobjects is an extension module for python that gives you access to
GLib's GObjects.

This package contains the Python Cairo bindings for GObject.

%if ! %{build_for_python3}
%package devel
Summary:        Python bindings for GObject
Group:          Development/Libraries/Python
Requires:       %{name} = %{version}
Requires:       python3-gobject = %{version}
# Until version 3.11.5, the -devel package contained python2 / python3 specifiecs
# AS this was cleared and the package no longer depends on the python version, the
# python3-gobject-devel package is no longer being built. In order to ease upgrades
# and remove the obsolete package, we obsolete/provide it here.
Obsoletes:      python3-gobject-devel < 3.11.5
Provides:       python3-gobject-devel = %{version}

%description devel
This package contains files required to build wrappers for gobject
addon libraries such as pygtk.
%endif

%prep
%setup -q -n %{_name}-%{version}
%patch1 -p1

%build
%if %{build_for_python3}
export PYTHON=python3
%else
export PYTHON=python2
%endif
%configure \
%if %{build_for_python3}
    --without-common
%endif

make %{?jobs:-j%jobs} V=1

%install
%makeinstall
find $RPM_BUILD_ROOT -name '*.la' -or -name '*.a' | xargs rm -f
# Drop pygtkcompat layer.it's useless and we lack other stuff for it to work
rm %{buildroot}%{local_py_sitedir}/gi/pygtkcompat.py
rm -r %{buildroot}%{local_py_sitedir}/pygtkcompat/
# Drop GIMarshallingTests - It's test suite remainders that should not be installed
find %{buildroot}%{local_py_sitedir}/gi -name GIMarshallingTests.py* -delete -print
rm examples/Makefile*
%fdupes $RPM_BUILD_ROOT

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc AUTHORS NEWS README ChangeLog examples
%{local_py_sitedir}/gi/
%{local_py_sitedir}/*.egg-info
# Lives in cairo subpackage
%exclude %{local_py_sitedir}/gi/_gi_cairo*.so
%exclude %{local_py_sitedir}/gi/overrides/Gdk.*
%exclude %{local_py_sitedir}/gi/overrides/Gtk.*
%exclude %{local_py_sitedir}/gi/overrides/keysyms.*

%files Gdk
%defattr(-,root,root)
%{local_py_sitedir}/gi/overrides/Gdk.*
%{local_py_sitedir}/gi/overrides/Gtk.*
%{local_py_sitedir}/gi/overrides/keysyms.*

%files cairo
%defattr(-,root,root)
%{local_py_sitedir}/gi/_gi_cairo*.so

%if ! %{build_for_python3}
%files devel
%defattr(-,root,root)
%{_includedir}/pygobject-3.0/
%{_libdir}/pkgconfig/pygobject-3.0.pc
%endif

%changelog
openSUSE Build Service is sponsored by