File libvirt-python.spec of Package libvirt-python
%define realname libvirt-python
%define realver 8.0.0
%define srcext tar.gz
# turn off the generation of debuginfo rpm (RH9) ??
%global debug_package %{nil}
%define python3_pkg python3
%define python3 %{_bindir}/python3
%if ! 0%{?py3_ver:1}
%define py3_ver %(%python3 -c "import sys; v=sys.version_info[:2]; print ('%%d.%%d'%%v)" 2>/dev/null || echo PYTHON3-NOT-FOUND)
%endif
%define py3_gen %(%python3 -c "import sys; v=sys.version_info[:2]; print ('%%d%%d'%%v)" 2>/dev/null || echo PYTHON3-NOT-FOUND)
%if ! 0%{?python3_sitelib:1}
%define python3_sitelib %(%python3 -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')
%endif
%if ! 0%{?python3_sitearch:1}
%define python3_sitearch %(%python3 -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib(True))')
%endif
%if 0%{?suse_version}
%define pkg_name %{python3_pkg}-libvirt
%define pkg_prov libvirt-python3 = %{version}-%{release}
%else
%define pkg_name libvirt-python3
%define pkg_prov %{python3_pkg}-libvirt = %{version}-%{release}
%endif
# Common info
Name: %{pkg_name}
Version: %{realver}
Release: wiz%{?extraver:0.}1%{?dist}
License: LGPL-2.0+
Group: Developemnt/Languages/Python
URL: https://libvirt.org/python.html
Summary: Python API bindings for libvirt
# Install-time parameters
Provides: %{pkg_prov}
Requires: python(abi) = %{py_ver}
BuildRequires: pkg-config
BuildRequires: %{python3_pkg}-devel
BuildRequires: pkgconfig(libvirt) = %{version}
BuildRoot: %{_tmppath}/%{name}-root
Source: http://libvirt.org/sources/python/%{realname}-%{realver}%{?extraver}.%{srcext}
%description
This package provides a python binding to the libvirt.so,
libvirt-qemu.so and libvirt-lxc.so library APIs.
# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver}
%build
export CFLAGS="%{optflags} %{?gcc_lto}"
export LDFLAGS="-Wl,--as-needed -Wl,--strip-all -Wl,-z,now -Wl,-z,relro %{?gcc_lto}"
%{python3} setup.py build
%install
export CFLAGS="%{optflags} %{?gcc_lto}"
export LDFLAGS="-Wl,--as-needed -Wl,--strip-all -Wl,-z,now -Wl,-z,relro %{?gcc_lto}"
%{python3} setup.py install --prefix=%{_prefix} --root=%{buildroot} -O2
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}
%files
%defattr(-,root,root)
%doc AUTHORS COPYING COPYING.LESSER README
%{python3_sitearch}/*
%changelog