Release of libvirt-python-4.5.0
[libvirt-python/ericb.git] / libvirt-python.spec.in
blob9697ea843ff38f9c96c2813e05ebbbf4b2369e87
1 # -*- rpm-spec -*-
3 # This spec file assumes you are building on a Fedora or RHEL version
4 # that's still supported by the vendor. It may work on other distros
5 # or versions, but no effort will be made to ensure that going forward
6 %define min_rhel 6
7 %define min_fedora 25
9 %if (0%{?fedora} && 0%{?fedora} >= %{min_fedora}) || (0%{?rhel} && 0%{?rhel} >= %{min_rhel})
10 %define supported_platform 1
11 %else
12 %define supported_platform 0
13 %endif
15 %define _with_python2 1
16 %if 0%{?fedora} > 29 || 0%{?rhel} > 7
17 %define _with_python2 0
18 %endif
20 %define _with_python3 0
21 %if 0%{?fedora} || 0%{?rhel} > 7
22 %define _with_python3 1
23 %endif
25 # Whether py2 packages are assumed to have python2- name prefix
26 %define py2_versioned_deps 0
27 %if 0%{?fedora} || 0%{?rhel} > 7
28 %define py2_versioned_deps 1
29 %endif
31 %{!?with_python2: %define with_python2 %{_with_python2}}
32 %{!?with_python3: %define with_python3 %{_with_python3}}
34 Summary: The libvirt virtualization API python2 binding
35 Name: libvirt-python
36 Version: @PY_VERSION@
37 Release: 1%{?dist}%{?extra_release}
38 Source0: http://libvirt.org/sources/python/%{name}-%{version}.tar.gz
39 Url: http://libvirt.org
40 License: LGPLv2+
41 Group: Development/Libraries
42 BuildRequires: libvirt-devel == %{version}
43 %if %{with_python2}
44 %if %{py2_versioned_deps}
45 BuildRequires: python2-devel
46 BuildRequires: python2-nose
47 BuildRequires: python2-lxml
48 %else
49 BuildRequires: python-devel
50 BuildRequires: python-nose
51 BuildRequires: python-lxml
52 %endif
53 %endif
54 %if %{with_python3}
55 BuildRequires: python3-devel
56 BuildRequires: python3-nose
57 BuildRequires: python3-lxml
58 %endif
60 # Don't want provides for python shared objects
61 %if %{with_python2}
62 %{?filter_provides_in: %filter_provides_in %{python_sitearch}/.*\.so}
63 %endif
64 %if %{with_python3}
65 %{?filter_provides_in: %filter_provides_in %{python3_sitearch}/.*\.so}
66 %endif
67 %{?filter_setup}
69 %description
70 The libvirt-python package contains a module that permits applications
71 written in the Python programming language to use the interface
72 supplied by the libvirt library to use the virtualization capabilities
73 of recent versions of Linux (and other OSes).
75 %if %{with_python2}
76 %package -n python2-libvirt
77 Summary: The libvirt virtualization API python2 binding
78 Url: http://libvirt.org
79 License: LGPLv2+
80 Group: Development/Libraries
81 %{?python_provide:%python_provide python2-libvirt}
82 Provides: libvirt-python = %{version}-%{release}
83 Obsoletes: libvirt-python <= 3.6.0-1%{?dist}
85 %description -n python2-libvirt
86 The python2-libvirt package contains a module that permits applications
87 written in the Python programming language to use the interface
88 supplied by the libvirt library to use the virtualization capabilities
89 of recent versions of Linux (and other OSes).
90 %endif
92 %if %{with_python3}
93 %package -n python3-libvirt
94 Summary: The libvirt virtualization API python3 binding
95 Url: http://libvirt.org
96 License: LGPLv2+
97 Group: Development/Libraries
98 %{?python_provide:%python_provide python3-libvirt}
99 Provides: libvirt-python3 = %{version}-%{release}
100 Obsoletes: libvirt-python3 <= 3.6.0-1%{?dist}
102 %description -n python3-libvirt
103 The python3-libvirt package contains a module that permits applications
104 written in the Python programming language to use the interface
105 supplied by the libvirt library to use the virtualization capabilities
106 of recent versions of Linux (and other OSes).
107 %endif
109 %prep
110 %setup -q
112 # Unset execute bit for example scripts; it can introduce spurious
113 # RPM dependencies, like /usr/bin/python which can pull in python2
114 # for the -python3 package
115 find examples -type f -exec chmod 0644 \{\} \;
117 %build
118 %if ! %{supported_platform}
119 echo "This RPM requires either Fedora >= %{min_fedora} or RHEL >= %{min_rhel}"
120 exit 1
121 %endif
123 %if %{with_python2}
124 CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py build
125 %endif
126 %if %{with_python3}
127 CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build
128 %endif
130 %install
131 %if %{with_python2}
132 %{__python} setup.py install --skip-build --root=%{buildroot}
133 %endif
134 %if %{with_python3}
135 %{__python3} setup.py install --skip-build --root=%{buildroot}
136 %endif
138 %check
139 %if %{with_python2}
140 %{__python} setup.py test
141 %endif
142 %if %{with_python3}
143 %{__python3} setup.py test
144 %endif
146 %if %{with_python2}
147 %files -n python2-libvirt
148 %defattr(-,root,root)
149 %doc ChangeLog AUTHORS NEWS README COPYING COPYING.LESSER examples/
150 %{python_sitearch}/libvirt.py*
151 %{python_sitearch}/libvirt_qemu.py*
152 %{python_sitearch}/libvirt_lxc.py*
153 %{python_sitearch}/libvirtmod*
154 %{python_sitearch}/*egg-info
155 %endif
157 %if %{with_python3}
158 %files -n python3-libvirt
159 %defattr(-,root,root)
160 %doc ChangeLog AUTHORS NEWS README COPYING COPYING.LESSER examples/
161 %{python3_sitearch}/libvirt.py*
162 %{python3_sitearch}/libvirtaio.py*
163 %{python3_sitearch}/libvirt_qemu.py*
164 %{python3_sitearch}/libvirt_lxc.py*
165 %{python3_sitearch}/__pycache__/libvirt.cpython-*.py*
166 %{python3_sitearch}/__pycache__/libvirt_qemu.cpython-*.py*
167 %{python3_sitearch}/__pycache__/libvirt_lxc.cpython-*.py*
168 %{python3_sitearch}/__pycache__/libvirtaio.cpython-*.py*
169 %{python3_sitearch}/libvirtmod*
170 %{python3_sitearch}/*egg-info
171 %endif
173 %changelog