A new user interface for you! Read more...

File libvirt-python.spec of Package libvirt-python

%define realname libvirt-python
%define realver  5.3.0
%define srcext   tar.gz

# turn off the generation of debuginfo rpm  (RH9) ??
%global debug_package %{nil}

%if ! 0%{?py_ver:1}
%define py_ver %(python -c "import sys; v=sys.version_info[:2]; print ('%%d.%%d'%%v)" 2>/dev/null || echo PYTHON-NOT-FOUND)
%endif

# Python 3.x
%if 0%{?suse_version}
%define python3_pkg python3
%define python3 python3
%endif

# EPEL
%if 0%{?rhel} == 6
%define python3_pkg python34
%define python3     python3.4
%endif
%if 0%{?rhel} == 7
%define python3_pkg python36
%define python3     python3.6
%endif

%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 python-libvirt
%define pkg_prov libvirt-python = %{version}-%{release}
%define pkg_name3 %{python3_pkg}-libvirt
%define pkg_prov3 libvirt-python3 = %{version}-%{release}
%else
%define pkg_name libvirt-python
%define pkg_prov python-libvirt = %{version}-%{release}
%define pkg_name3 libvirt-python3
%define pkg_prov3 %{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: pkgconfig
BuildRequires: python-devel
BuildRequires: %{python3_pkg}-devel
BuildRequires: pkgconfig(libvirt) = %{version}
%if 0%{?suse_version}
BuildRequires: python-xml
%endif
%if 0%{?rhel} && 0%{?rhel} < 7
BuildRequires: PyXML
%endif
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.

%package -n %{pkg_name3}
Group:         Developemnt/Languages/Python
Summary:       Python 3.x API bindings for libvirt
Provides:      %{pkg_prov3}
Requires:      python(abi) = %{py3_ver}

%description -n %{pkg_name3}
This package provides a python 3.x 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} -c -T -a0
mv %{realname}-%{version}%{?extraver} python2
cp -r python2 python3

%build
export CFLAGS="%{optflags} %{?gcc_lto}"
export LDFLAGS="-Wl,--as-needed -Wl,--strip-all -Wl,-z,now -Wl,-z,relro %{?gcc_lto}"
cd python2
python setup.py build
cd ../python3
%{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}"
cd python2
python setup.py install --prefix=%{_prefix} --root=%{buildroot} -O2
cd ../python3
%{python3} setup.py install --prefix=%{_prefix} --root=%{buildroot} -O2

%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

%files
%defattr(-,root,root)
%doc python2/AUTHORS python2/COPYING python2/COPYING.LESSER python2/NEWS python2/README
%{python_sitearch}/*

%files -n %{pkg_name3}
%defattr(-,root,root)
%doc python3/AUTHORS python3/COPYING python3/COPYING.LESSER python3/NEWS python3/README
%{python3_sitearch}/*

%changelog