File saltbundlepy-pycairo.spec of Package saltbundlepy-pycairo

#
# spec file for package saltbundlepy-pycairo
#
# Copyright (c) 2024 SUSE LLC
#
# 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/
#

AutoReqProv: no

%{?!saltbundlepy_module:%define saltbundlepy_module() saltbundlepy-%{**}}
%define pythons saltbundlepy

# Disable python bytecompile for all distros
# It's called explicitly in the spec
%global __brp_python_bytecompile %{nil}

%bcond_with common-devel

Name:           saltbundlepy-pycairo
Version:        1.23.0
Release:        0
Summary:        Python Bindings for Cairo
License:        LGPL-2.1-or-later OR MPL-1.1
URL:            https://github.com/pygobject/pycairo
Source:         %{url}/releases/download/v%{version}/pycairo-%{version}.tar.gz

BuildRequires:  %{saltbundlepy_module devel}
BuildRequires:  %{saltbundlepy_module pytest}
BuildRequires:  %{saltbundlepy_module setuptools}
BuildRequires:  cairo-devel >= 1.15.10
BuildRequires:  fdupes
BuildRequires:  saltbundlepy-rpm-macros
Provides:       saltbundlepy-cairo = %{version}
Obsoletes:      saltbundlepy-cairo < %{version}
%python_subpackages

%description
Pycairo is a Python module providing bindings for the cairo graphics library.

%package        devel
Summary:        Development files for the Cairo Python bindings
Requires:       saltbundlepy-devel
Requires:       saltbundlepy-pycairo = %{version}
%if %{with common-devel}
Requires:       saltbundlepy-pycairo-common-devel = %{version}
%endif
Provides:       saltbundlepy-cairo-devel = %{version}
Obsoletes:      saltbundlepy-cairo-devel < %{version}

%description   devel
Pycairo is a Python module providing bindings for the cairo graphics library.

This package provides the development files needed to build
packages that depend on Pycairo.

%package     -n saltbundlepy-pycairo-common-devel
Summary:        Headers for the Cairo Python bindings
Requires:       cairo-devel
Provides:       %{saltbundlepy_module cairo-common-devel = %{version}}
Provides:       %{saltbundlepy_module pycairo-common-devel = %{version}}
Obsoletes:      %{saltbundlepy_module cairo-common-devel < %{version}}
Provides:       %{saltbundlepy_module cairo-devel = %{version}}
Obsoletes:      %{saltbundlepy_module cairo-devel < %{version}}
Provides:       saltbundlepy-cairo-common-devel = %{version}
Obsoletes:      saltbundlepy-cairo-common-devel < %{version}

%description -n saltbundlepy-pycairo-common-devel
Pycairo is a Python module providing bindings for the cairo graphics library.

This package provides the headers and development files needed to build
packages that depend on Pycairo.

%prep
%autosetup -n pycairo-%{version} -p1

%build
%python_build

%install
%python_install
# Incorrectly installed by a python38-setuptools vendored distutils
# which does not play well with the distro patched python38.
# Later flavors installed the correct files into lib64 as well
if [ "%{_libdir}" != "%{_prefix}/lib" -a -d %{buildroot}%{_prefix}/lib/pkgconfig ]; then
  rm -r  %{buildroot}%{_prefix}/lib/pkgconfig
fi

%if %{without common-devel}
%{python_expand #
# No common-devel package so we place all files for the devel package
mkdir -p %{buildroot}%{$python_sitearch}/cairo/share/pkgconfig/
mv %{buildroot}%{_libdir}/pkgconfig/py3cairo.pc %{buildroot}%{$python_sitearch}/cairo/share/pkgconfig/py3cairo.pc
sed -i "s|%{_prefix}|%{$python_sitearch}/cairo|g" %{buildroot}%{$python_sitearch}/cairo/share/pkgconfig/py3cairo.pc
sed -i "s|include/pycairo|include|g" %{buildroot}%{$python_sitearch}/cairo/share/pkgconfig/py3cairo.pc
# These files are also inside the python_sitearch so it's not needed if
# there's no common-devel package
rm -rf %{buildroot}%{_includedir}/pycairo/
rm -rf %{buildroot}%{_libdir}/pkgconfig
}
%endif

%python_expand %fdupes %{buildroot}%{$python_sitearch}

%check
# this is not the deprecated setuptools test call but a custom setup compiling stuff and running pytest
%python_exec setup.py test

%files %{python_files}
%doc NEWS docs
%license COPYING COPYING-LGPL-2.1 COPYING-MPL-1.1
%{python_sitearch}/cairo/
%exclude %{python_sitearch}/cairo/include
%{python_sitearch}/pycairo-*.egg-info

%if %{without common-devel}
%exclude %{python_sitearch}/cairo/share
%endif

%files %{python_files devel}
%license COPYING COPYING-LGPL-2.1 COPYING-MPL-1.1
%{python_sitearch}/cairo/include

%if %{without common-devel}
# no common-devel package so all devel files should be here
%{python_sitearch}/cairo/share/

%else

%files -n saltbundlepy-pycairo-common-devel
%license COPYING COPYING-LGPL-2.1 COPYING-MPL-1.1
%{_includedir}/pycairo/
%{_libdir}/pkgconfig/py3cairo.pc
%endif

%changelog
openSUSE Build Service is sponsored by