# Last updated for version 3.18.0
%global glib2_version                  2.38.0
%global gobject_introspection_version  1.46.0
%global confopts --disable-silent-rules --srcdir=..

Name:		python3-gobject3
Version:	3.22.0
Release:	6%{?dist}
Summary:	Python %{python3_version} bindings for GObject Introspection
License:	LGPLv2+ and MIT
URL:		https://wiki.gnome.org/Projects/PyGObject
Source0:	https://download.gnome.org/sources/pygobject/3.22/pygobject-%{version}.tar.xz
# https://bugzilla.redhat.com/1247996
# which reverts https://bugzilla.gnome.org/709183
Patch1:		pygobject-3.22.0-allow-static-module-import.patch
Patch2:		pygobject-3.22.0-remove-Werror.patch
BuildRequires:	glib2-devel >= %{glib2_version}
BuildRequires:	gobject-introspection-devel >= %{gobject_introspection_version}
BuildRequires:	python3-devel
BuildRequires:	python3-cairo-devel
BuildRequires:	cairo-gobject-devel


%description
The %{name} package provides a convenient wrapper for the GObject
library and and other libraries that are compatible with GObject Introspection,
for use in Python %{python3_version} programs.


%package -n python3-gobject
Summary:	Python 3 bindings for GObject Introspection
Requires:	python3-gobject-base%{?_isa} = %{version}-%{release}
Requires:	python3-cairo%{?_isa}
%description -n python3-gobject
The %{name} package provides a convenient wrapper for the GObject
library and and other libraries that are compatible with GObject Introspection,
for use in Python %{python3_version} programs.


%package -n python3-gobject-base
Summary:	Python %{python3_version} bindings for GObject Introspection base package
Requires:	gobject-introspection%{?_isa} >= %{gobject_introspection_version}
%description -n python%{python3_pkgversion}-gobject-base
This package provides the non-cairo specific bits of the GObject Introspection
library.


%package -n python3-gobject-devel
Summary:	Development files for embedding Python %{python3_version} GObject introspection support
Requires:	python%{python3_pkgversion}-gobject%{?_isa} = %{version}-%{release}
Requires:	gobject-introspection-devel%{?_isa}
%description -n python%{python3_pkgversion}-gobject-devel
This package contains files required to embed Python %{python3_version} PyGObject.


%prep
%autosetup -n pygobject-%{version} -p 1
%{_bindir}/find . -name '*.py' | %{_bindir}/xargs %{__sed} -i '1s|^#!python|#!%{__python3}|'


%build
%{__mkdir} -p python3
pushd python3
export PYTHON=%{__python3}
%{__ln_s} ../configure configure
%configure %{confopts}
make %{?_smp_mflags} V=1
popd


%install
export PYTHON=%{__python3}
%make_install -C python3
%{_bindir}/find %{buildroot} -name '*.la' -delete
# Don't include makefiles in the installed docs, in order to avoid creating
# multilib conflicts
%{__rm} -fr _docs
%{__mkdir} _docs
%{__cp} -a examples _docs
%{__rm} _docs/examples/Makefile*


%files -n python3-gobject
%{python3_sitearch}/gi/_gi_cairo*.so


%files -n python3-gobject-base
%license COPYING
%doc AUTHORS NEWS README
%dir %{python3_sitearch}/gi
%{python3_sitearch}/gi/*
%exclude %{python3_sitearch}/gi/_gi_cairo*.so
%{python3_sitearch}/pygobject-*.egg-info
%{python3_sitearch}/pygtkcompat/


%files -n python3-gobject-devel
%doc _docs/*
%dir %{_includedir}/pygobject-3.0/
%{_includedir}/pygobject-3.0/pygobject.h
%{_libdir}/pkgconfig/pygobject-3.0.pc


%changelog
